mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-15 14:45:43 +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
73 lines
2.4 KiB
TypeScript
73 lines
2.4 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 type { IpcMainHandler } from './ipc-main-handler.js';
|
|
|
|
import * as tmp from 'tmp';
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-ignore Warned on by nodenext resolution (while package does build in bundler mode)
|
|
import { FileStore } from '@pezkuwi/ui-keyring/stores';
|
|
|
|
import { accountStoreIpcHandler } from './account-store.js';
|
|
|
|
const exampleAccount = (address: string): KeyringJson => ({
|
|
address,
|
|
meta: {}
|
|
});
|
|
|
|
describe('Account store', () => {
|
|
let accountStore: IpcMainHandler;
|
|
let tmpDir: tmp.DirResult;
|
|
|
|
beforeEach(() => {
|
|
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
|
accountStore = accountStoreIpcHandler(new FileStore(tmpDir.name));
|
|
});
|
|
|
|
afterEach(() => {
|
|
tmpDir.removeCallback();
|
|
});
|
|
|
|
it('all returns empty array at first', () => {
|
|
expect(accountStore['account-store-all']()).toEqual([]);
|
|
});
|
|
|
|
it('after adding accounts, they become visible', async () => {
|
|
await accountStore['account-store-set']('1', exampleAccount('a'));
|
|
await accountStore['account-store-set']('2', exampleAccount('b'));
|
|
|
|
expect(accountStore['account-store-all']()).toEqual([{
|
|
key: '1', value: exampleAccount('a')
|
|
}, {
|
|
key: '2', value: exampleAccount('b')
|
|
}]);
|
|
});
|
|
|
|
it('get returns account if exists', async () => {
|
|
await accountStore['account-store-set']('1', exampleAccount('a'));
|
|
expect(await accountStore['account-store-get']('1')).toEqual(exampleAccount('a'));
|
|
});
|
|
|
|
it('get returns null if account does not exist', async () => {
|
|
// jest.spyOn(console, 'error').mockImplementationOnce(() => { /**/ });
|
|
|
|
expect(await accountStore['account-store-get']('1')).toEqual(null);
|
|
});
|
|
|
|
it('account disappears from list after it is removed', async () => {
|
|
// jest.spyOn(console, 'error').mockImplementationOnce(() => { /**/ });
|
|
|
|
await accountStore['account-store-set']('1', exampleAccount('a'));
|
|
await accountStore['account-store-remove']('1');
|
|
|
|
expect(await accountStore['account-store-get']('1')).toEqual(null);
|
|
expect(accountStore['account-store-all']()).toEqual([]);
|
|
});
|
|
});
|