-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auth-client stores identities in indexeddb (#605)
* feat: adds IdbStorage as new default for auth-client * Adds IdbKeyVal interface
- Loading branch information
Showing
9 changed files
with
501 additions
and
74 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'fake-indexeddb/auto'; | ||
import { IdbKeyVal } from './db'; | ||
|
||
let testCounter = 0; | ||
|
||
const testDb = async () => { | ||
return await IdbKeyVal.create({ | ||
dbName: 'db-' + testCounter, | ||
storeName: 'store-' + testCounter, | ||
}); | ||
}; | ||
|
||
beforeEach(() => { | ||
testCounter += 1; | ||
}); | ||
|
||
describe('indexeddb wrapper', () => { | ||
it('should store a basic key value', async () => { | ||
const db = await testDb(); | ||
const shouldSet = async () => await db.set('testKey', 'testValue'); | ||
expect(shouldSet).not.toThrow(); | ||
|
||
expect(await db.get('testKey')).toBe('testValue'); | ||
}); | ||
it('should support removing a value', async () => { | ||
const db = await testDb(); | ||
await db.set('testKey', 'testValue'); | ||
|
||
expect(await db.get('testKey')).toBe('testValue'); | ||
|
||
await db.remove('testKey'); | ||
|
||
expect(await db.get('testKey')).toBe(null); | ||
}); | ||
}); |
Oops, something went wrong.