-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: single loop to query wallet relay responses
- Loading branch information
1 parent
42b044f
commit 8e1a5d9
Showing
3 changed files
with
162 additions
and
78 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
packages/dapp-toolkit/src/modules/storage/local-storage.module.spec.ts
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,69 @@ | ||
/** | ||
* @vitest-environment jsdom | ||
*/ | ||
|
||
import { beforeEach, describe, expect, it } from 'vitest' | ||
import { LocalStorageModule, StorageModule } from './local-storage.module' | ||
import { ResultAsync } from 'neverthrow' | ||
|
||
describe('LocalStorageModule', () => { | ||
let storageModule: StorageModule | ||
|
||
beforeEach(() => { | ||
storageModule = LocalStorageModule(`rdt:${crypto.randomUUID()}:1`) | ||
}) | ||
|
||
it('should store and read data', async () => { | ||
await storageModule.setState({ key: 'value' }) | ||
const data = await storageModule.getState() | ||
expect(data.isOk() && data.value).toEqual({ key: 'value' }) | ||
}) | ||
|
||
describe('getItemById', () => { | ||
it('should get specific item', async () => { | ||
await storageModule.setState({ specific: 'value', key: 'value' }) | ||
const data = await storageModule.getItemById('specific') | ||
expect(data.isOk() && data.value).toEqual('value') | ||
}) | ||
}) | ||
|
||
describe('setItems', () => { | ||
it('should set multiple items separately', async () => { | ||
await storageModule.setItems({ | ||
specific: 'value', | ||
}) | ||
|
||
await storageModule.setItems({ key: 'value' }) | ||
const data = await storageModule.getItems() | ||
expect(data.isOk() && data.value).toEqual({ | ||
specific: 'value', | ||
key: 'value', | ||
}) | ||
}) | ||
|
||
// TODO: This currently fails. Uncomment this test when working on RDT-225 and ensure it's passing | ||
it.skip('should set multiple items at once', async () => { | ||
await ResultAsync.combine([ | ||
storageModule.setItems({ | ||
specific: 'value', | ||
}), | ||
storageModule.setItems({ key: 'value' }), | ||
]) | ||
|
||
const data = await storageModule.getItems() | ||
expect(data.isOk() && data.value).toEqual({ | ||
specific: 'value', | ||
key: 'value', | ||
}) | ||
}) | ||
}) | ||
|
||
describe('removeItemById', () => { | ||
it('should remove specific item', async () => { | ||
await storageModule.setState({ specific: 'value', key: 'value' }) | ||
await storageModule.removeItemById('specific') | ||
const data = await storageModule.getState() | ||
expect(data.isOk() && data.value).toEqual({ key: 'value' }) | ||
}) | ||
}) | ||
}) |
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