-
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: RCfM interactions getting stuck (#253)
* chore: remove obsolete `callbackPath` * chore: fix watch in dev mode * chore: change example dapp configuration * fix: single loop to query wallet relay responses
- Loading branch information
1 parent
b7e44eb
commit b0afda3
Showing
6 changed files
with
169 additions
and
85 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
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