mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-12 16:55:48 +00:00
971df8edba
- Remove all 3rd party parachain configurations from endpoints: - productionRelayPolkadot.ts: Keep only system parachains - productionRelayDicle.ts: Keep only system parachains - testingRelayZagros.ts: Keep only system parachains - testingRelayTeyrChain.ts: Keep only system parachains - Update domain references: - polkadot.js.org → pezkuwichain.app - wiki.polkadot.network → wiki.pezkuwichain.io - dotapps.io → pezkuwichain.app - statement.polkadot.network → docs.pezkuwichain.io/statement - support.polkadot.network → docs.pezkuwichain.io - Update repository references: - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap - Rename system parachains to Pezkuwi ecosystem: - PolkadotAssetHub → PezkuwiAssetHub - polkadotBridgeHub → pezkuwiBridgeHub - polkadotCollectives → pezkuwiCollectives - polkadotCoretime → pezkuwiCoretime - polkadotPeople → pezkuwiPeople - Update network name in claims utility: - Polkadot → Pezkuwi
96 lines
2.5 KiB
TypeScript
96 lines
2.5 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/apps authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-ignore Warned on by nodenext resolution (while package does build in bundler mode)
|
|
import type { KeyringJson } from '@pezkuwi/ui-keyring/types';
|
|
|
|
import { RemoteElectronStore } from './remote-electron-store.js';
|
|
|
|
describe('Remote Electron Store', () => {
|
|
const accountStore = {
|
|
all: jest.fn(),
|
|
get: jest.fn(),
|
|
remove: jest.fn(),
|
|
set: jest.fn()
|
|
};
|
|
const remoteStore = new RemoteElectronStore(accountStore);
|
|
|
|
beforeEach(() => {
|
|
accountStore.all.mockClear();
|
|
accountStore.get.mockClear();
|
|
accountStore.remove.mockClear();
|
|
accountStore.set.mockClear();
|
|
});
|
|
|
|
describe('all', () => {
|
|
it('calls callback for each returned account', async () => {
|
|
accountStore.all.mockResolvedValue([{
|
|
key: 1,
|
|
value: 'a'
|
|
}, {
|
|
key: 2,
|
|
value: 'b'
|
|
}]);
|
|
const cb = jest.fn();
|
|
|
|
remoteStore.all(cb);
|
|
await Promise.resolve();
|
|
|
|
expect(cb).toHaveBeenNthCalledWith(1, 1, 'a');
|
|
expect(cb).toHaveBeenNthCalledWith(2, 2, 'b');
|
|
});
|
|
});
|
|
|
|
describe('get', () => {
|
|
it('calls callback with returned account', async () => {
|
|
accountStore.get.mockResolvedValue('a');
|
|
const cb = jest.fn();
|
|
|
|
remoteStore.get('1', cb);
|
|
await Promise.resolve();
|
|
|
|
expect(accountStore.get).toHaveBeenCalledWith('1');
|
|
expect(cb).toHaveBeenCalledWith('a');
|
|
});
|
|
|
|
it('calls callback with null if no accounts found', async () => {
|
|
accountStore.get.mockResolvedValue(null);
|
|
const cb = jest.fn();
|
|
|
|
remoteStore.get('1', cb);
|
|
await Promise.resolve();
|
|
|
|
expect(cb).toHaveBeenCalledWith(null);
|
|
});
|
|
});
|
|
|
|
describe('remove', () => {
|
|
it('calls callback after success', async () => {
|
|
accountStore.remove.mockResolvedValue(null);
|
|
const cb = jest.fn();
|
|
|
|
remoteStore.remove('1', cb);
|
|
await Promise.resolve();
|
|
|
|
expect(accountStore.remove).toHaveBeenCalledWith('1');
|
|
expect(cb).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|
|
|
|
describe('set', () => {
|
|
it('calls callback after success', async () => {
|
|
accountStore.set.mockResolvedValue(null);
|
|
const cb = jest.fn();
|
|
|
|
remoteStore.set('1', 'a' as unknown as KeyringJson, cb);
|
|
await Promise.resolve();
|
|
|
|
expect(accountStore.set).toHaveBeenCalledWith('1', 'a');
|
|
expect(cb).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|
|
});
|