-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #294 from gbmhunter/develop
Release of v4.10.1.
- Loading branch information
Showing
7 changed files
with
86 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,45 @@ | ||
import { expect, test } from 'vitest' | ||
import { expect, test, describe, beforeEach } from 'vitest' | ||
|
||
import AppStorage from './AppStorage'; | ||
|
||
test('get config returns null when nothing stored there', () => { | ||
const appStorage = new AppStorage(); | ||
const value = appStorage.getConfig(['prop1', 'prop2']); | ||
expect(value).toEqual(null); | ||
beforeEach(() => { | ||
// Clear local storage, because otherwise jsdom persists storage | ||
// between tests | ||
window.localStorage.clear(); | ||
}) | ||
|
||
test('basic get and set works', () => { | ||
const appStorage = new AppStorage(); | ||
appStorage.saveConfig(['prop1', 'prop2'], 'hello'); | ||
const value = appStorage.getConfig(['prop1', 'prop2']); | ||
expect(value).toEqual('hello'); | ||
}) | ||
describe('config tests', () => { | ||
test('get config returns null when nothing stored there', () => { | ||
const appStorage = new AppStorage(); | ||
const value = appStorage.getConfig(['prop1', 'prop2']); | ||
expect(value).toEqual(null); | ||
}) | ||
|
||
test('basic get and set works', () => { | ||
const appStorage = new AppStorage(); | ||
appStorage.saveConfig(['prop1', 'prop2'], 'hello'); | ||
const value = appStorage.getConfig(['prop1', 'prop2']); | ||
expect(value).toEqual('hello'); | ||
}) | ||
|
||
test('can get parent key and see child', () => { | ||
const appStorage = new AppStorage(); | ||
appStorage.saveConfig(['prop1', 'prop2'], 'hello'); | ||
const value = appStorage.getConfig(['prop1']); | ||
expect(value).toEqual({ prop2: 'hello' }); | ||
}) | ||
|
||
test('can read back root config', () => { | ||
const appStorage = new AppStorage(); | ||
appStorage.saveConfig(['prop1', 'prop2'], 'hello'); | ||
const value = appStorage.getConfig([]); | ||
expect(value).toEqual({ prop1: { prop2: 'hello' } }); | ||
}) | ||
|
||
test('can set root config', () => { | ||
const appStorage = new AppStorage(); | ||
appStorage.saveConfig([], 'hello'); | ||
const value = appStorage.getConfig([]); | ||
expect(value).toEqual('hello'); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters