From 699de52dc96ef714b52b0ac2df906dbc0e94cbe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E5=9B=BD=E5=AE=87?= <841185308@qq.com> Date: Tue, 10 Oct 2023 13:52:32 +0800 Subject: [PATCH] chore: Fix files code style (#2864) --- packages/neuron-ui/.storybook/.babelrc | 5 +- packages/neuron-ui/.storybook/electron.js | 6 +- packages/neuron-ui/.storybook/preview.tsx | 25 ++++--- packages/neuron-ui/public/css/fonts.css | 10 +-- packages/neuron-ui/public/index.html | 32 ++++---- .../balanceSyncIcon.module.scss | 2 +- .../SendFieldset/sendFieldset.module.scss | 2 +- .../WalletWizard/walletWizard.module.scss | 6 +- packages/neuron-ui/src/stories/styles.scss | 3 +- .../src/widgets/Calendar/calendar.module.scss | 74 +++++++++---------- .../copyZoneAddress.module.scss | 2 +- .../datetimePickerDialog.module.scss | 2 +- .../DropdownButton/dropdownButton.module.scss | 2 +- .../widgets/MnemonicInput/index.module.scss | 12 +-- .../src/widgets/Select/select.module.scss | 11 ++- .../indexer-cache-service.intg.test.ts | 34 +++++---- .../tests/controllers/export-debug.test.ts | 6 +- .../tests/controllers/sync-api.test.ts | 8 +- .../tests/models/chain/fixtures/tx.json | 5 +- .../tests/models/chain/live-cell.test.ts | 2 +- .../tests/services/ckb-runner.test.ts | 6 +- .../tests/services/indexer.test.ts | 12 +-- .../tests/services/light-runner.test.ts | 38 ++++++---- .../neuron-wallet/tests/utils/ckb-rpc.test.ts | 2 +- .../tests/utils/fixtures/worker.js | 9 +-- 25 files changed, 163 insertions(+), 153 deletions(-) diff --git a/packages/neuron-ui/.storybook/.babelrc b/packages/neuron-ui/.storybook/.babelrc index c0993b53fd..3313ff9ef0 100644 --- a/packages/neuron-ui/.storybook/.babelrc +++ b/packages/neuron-ui/.storybook/.babelrc @@ -1,6 +1,3 @@ { - "presets": [ - "@babel/preset-env", - "@babel/preset-typescript" - ] + "presets": ["@babel/preset-env", "@babel/preset-typescript"] } diff --git a/packages/neuron-ui/.storybook/electron.js b/packages/neuron-ui/.storybook/electron.js index 38f9aa5b6b..78003d8100 100644 --- a/packages/neuron-ui/.storybook/electron.js +++ b/packages/neuron-ui/.storybook/electron.js @@ -1,6 +1,6 @@ const sendSyncValues = { 'get-locale': 'zh', - 'get-version': '0.103.1' + 'get-version': '0.103.1', } module.exports = { @@ -12,10 +12,10 @@ module.exports = { return Promise.resolve({}) }, on() {}, - removeAllListeners() {} + removeAllListeners() {}, }, clipboard() {}, nativeImage() {}, shell() {}, - desktopCapturer() {} + desktopCapturer() {}, } diff --git a/packages/neuron-ui/.storybook/preview.tsx b/packages/neuron-ui/.storybook/preview.tsx index d309b30e90..e77da948c7 100644 --- a/packages/neuron-ui/.storybook/preview.tsx +++ b/packages/neuron-ui/.storybook/preview.tsx @@ -9,31 +9,38 @@ import { action } from '@storybook/addon-actions' import { NeuronWalletContext, initStates } from '../src/states' export const parameters = { - actions: { argTypesRegex: "^on[A-Z].*" }, + actions: { argTypesRegex: '^on[A-Z].*' }, controls: { matchers: { color: /(background|color)$/i, date: /Date$/, }, - } + }, } const dispatch = action('Dispatch') -BigInt.prototype['toJSON'] = function() { return this.toString() } +BigInt.prototype['toJSON'] = function () { + return this.toString() +} export const decorators = [ (Story, { argTypes, args }) => { const globalArgTypes = Object.keys(argTypes).filter(v => argTypes[v]?.isGlobal) - const globalStates = globalArgTypes.reduce((pre, cur) => args[cur] ? ({ - ...pre, - [cur]: args[cur] - }) : pre, initStates) + const globalStates = globalArgTypes.reduce( + (pre, cur) => + args[cur] + ? { + ...pre, + [cur]: args[cur], + } + : pre, + initStates + ) return ( ) }, -]; - +] diff --git a/packages/neuron-ui/public/css/fonts.css b/packages/neuron-ui/public/css/fonts.css index 3f63aff9a7..85b52a469f 100644 --- a/packages/neuron-ui/public/css/fonts.css +++ b/packages/neuron-ui/public/css/fonts.css @@ -11,29 +11,29 @@ @font-face { font-family: 'ProximaNova-Regular'; src: url('../fonts/ProximaNova-Regular.otf') format('opentype'), - url('../fonts//Proximanova-Regular.ttf') format('opentype'); + url('../fonts//Proximanova-Regular.ttf') format('opentype'); } @font-face { font-family: 'ProximaNova-Semibold'; src: url('../fonts/ProximaNova-Semibold.otf') format('opentype'), - url('../fonts/ProximaNova-Semibold.ttf') format('opentype'); + url('../fonts/ProximaNova-Semibold.ttf') format('opentype'); } @font-face { font-family: 'D-DIN-PRO'; src: url('../fonts/D-DIN-PRO-500-Medium.otf') format('opentype'), - url('../fonts/D-DIN-PRO-500-Medium.ttf') format('opentype'); + url('../fonts/D-DIN-PRO-500-Medium.ttf') format('opentype'); } @font-face { font-family: 'JetBrains Mono Medium'; src: url('../fonts/JetBrainsMonoNL-Medium.otf') format('opentype'), - url('../fonts/JetBrainsMonoNL-Medium.ttf') format('opentype'); + url('../fonts/JetBrainsMonoNL-Medium.ttf') format('opentype'); } @font-face { font-family: 'JetBrains Mono'; src: url('../fonts/JetBrainsMonoNL-Regular.otf') format('opentype'), - url('../fonts/JetBrainsMonoNL-Regular.ttf') format('opentype'); + url('../fonts/JetBrainsMonoNL-Regular.ttf') format('opentype'); } diff --git a/packages/neuron-ui/public/index.html b/packages/neuron-ui/public/index.html index e0afb78b63..bbfb71d586 100755 --- a/packages/neuron-ui/public/index.html +++ b/packages/neuron-ui/public/index.html @@ -1,13 +1,12 @@ - - - - - - - - - Neuron - - - - -
-
-
- + Neuron + + + +
+
+
+ diff --git a/packages/neuron-ui/src/components/BalanceSyncingIcon/balanceSyncIcon.module.scss b/packages/neuron-ui/src/components/BalanceSyncingIcon/balanceSyncIcon.module.scss index cbb7fb7400..116c7a0466 100644 --- a/packages/neuron-ui/src/components/BalanceSyncingIcon/balanceSyncIcon.module.scss +++ b/packages/neuron-ui/src/components/BalanceSyncingIcon/balanceSyncIcon.module.scss @@ -5,6 +5,6 @@ margin-left: 4px; path { - fill: #FFFFFF; + fill: #ffffff; } } diff --git a/packages/neuron-ui/src/components/SendFieldset/sendFieldset.module.scss b/packages/neuron-ui/src/components/SendFieldset/sendFieldset.module.scss index 8d6b988f46..651cb0407d 100644 --- a/packages/neuron-ui/src/components/SendFieldset/sendFieldset.module.scss +++ b/packages/neuron-ui/src/components/SendFieldset/sendFieldset.module.scss @@ -139,6 +139,6 @@ $textfieldWidth: calc(100vw - 370px); } } } -.textFieldClass{ +.textFieldClass { margin-bottom: 10px; } diff --git a/packages/neuron-ui/src/components/WalletWizard/walletWizard.module.scss b/packages/neuron-ui/src/components/WalletWizard/walletWizard.module.scss index 7735996fdd..3d1a00bf46 100644 --- a/packages/neuron-ui/src/components/WalletWizard/walletWizard.module.scss +++ b/packages/neuron-ui/src/components/WalletWizard/walletWizard.module.scss @@ -107,12 +107,12 @@ $line-gap: 15px; .submission { padding-top: 96px; - + .title { @include header-title; margin-bottom: 16px; } - + .input { width: 500px; margin: 0 auto; @@ -191,4 +191,4 @@ $line-gap: 15px; margin-bottom: 24px; animation: rotating 3s linear infinite; } -} \ No newline at end of file +} diff --git a/packages/neuron-ui/src/stories/styles.scss b/packages/neuron-ui/src/stories/styles.scss index 2fb181508b..b6986b8fd9 100644 --- a/packages/neuron-ui/src/stories/styles.scss +++ b/packages/neuron-ui/src/stories/styles.scss @@ -3,8 +3,7 @@ body { border: 2px solid #fff; box-sizing: border-box; background-color: lightslategrey; - background-image: linear-gradient(white 2px, transparent 2px), - linear-gradient(90deg, white 2px, transparent 2px), + background-image: linear-gradient(white 2px, transparent 2px), linear-gradient(90deg, white 2px, transparent 2px), linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px); background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px; diff --git a/packages/neuron-ui/src/widgets/Calendar/calendar.module.scss b/packages/neuron-ui/src/widgets/Calendar/calendar.module.scss index 76d9aa0b86..1a24b471f8 100644 --- a/packages/neuron-ui/src/widgets/Calendar/calendar.module.scss +++ b/packages/neuron-ui/src/widgets/Calendar/calendar.module.scss @@ -13,7 +13,7 @@ border: none; background-color: transparent; min-width: 0; - color: var(--main-text-color); + color: var(--main-text-color); &[disabled] { cursor: not-allowed; color: var(--disable-button-text-color); @@ -50,29 +50,29 @@ .calendarHeader { display: flex; justify-content: space-between; - align-items: center; + align-items: center; .calPrev, .calNext { - background: transparent; - border: none; - cursor: pointer; - svg { - g, - path { - stroke: var(--main-text-color) - } - } + background: transparent; + border: none; + cursor: pointer; + svg { + g, + path { + stroke: var(--main-text-color); + } + } } .calPrev { order: 1; - &[disabled] { - svg { - g, - path { - stroke: var(--disable-button-text-color) - } - } + &[disabled] { + svg { + g, + path { + stroke: var(--disable-button-text-color); + } + } } } .calNext { @@ -84,29 +84,29 @@ margin: 0; font-size: 16px; line-height: 22px; - color: var(--main-text-color); + color: var(--main-text-color); } } .calendarTable { width: 100%; - thead { - position: relative; - tr { - height: 40px; - color: var(--main-text-color) - } - &::after { - position: absolute; - content: ""; - background: var(--input-border-color); - left: 0; - bottom: -0; - height: 1px; - width: 100%; - } - } + thead { + position: relative; + tr { + height: 40px; + color: var(--main-text-color); + } + &::after { + position: absolute; + content: ''; + background: var(--input-border-color); + left: 0; + bottom: -0; + height: 1px; + width: 100%; + } + } td { text-align: center; @@ -115,8 +115,8 @@ button { &:hover, &:focus { - color: #fff; - background-color: var(--primary-color); + color: #fff; + background-color: var(--primary-color); } } diff --git a/packages/neuron-ui/src/widgets/CopyZoneAddress/copyZoneAddress.module.scss b/packages/neuron-ui/src/widgets/CopyZoneAddress/copyZoneAddress.module.scss index c491ee320e..a2296ad384 100644 --- a/packages/neuron-ui/src/widgets/CopyZoneAddress/copyZoneAddress.module.scss +++ b/packages/neuron-ui/src/widgets/CopyZoneAddress/copyZoneAddress.module.scss @@ -14,4 +14,4 @@ & > span { line-height: 1.625rem; } -} \ No newline at end of file +} diff --git a/packages/neuron-ui/src/widgets/DatetimePickerDialog/datetimePickerDialog.module.scss b/packages/neuron-ui/src/widgets/DatetimePickerDialog/datetimePickerDialog.module.scss index d6fcb60a61..e213fc0688 100644 --- a/packages/neuron-ui/src/widgets/DatetimePickerDialog/datetimePickerDialog.module.scss +++ b/packages/neuron-ui/src/widgets/DatetimePickerDialog/datetimePickerDialog.module.scss @@ -64,7 +64,7 @@ font-size: 14px; line-height: 24px; background: var(--secondary-background-color); - color: var(--main-text-color) + color: var(--main-text-color); } } diff --git a/packages/neuron-ui/src/widgets/DropdownButton/dropdownButton.module.scss b/packages/neuron-ui/src/widgets/DropdownButton/dropdownButton.module.scss index f998b4b1e9..6e27b46264 100644 --- a/packages/neuron-ui/src/widgets/DropdownButton/dropdownButton.module.scss +++ b/packages/neuron-ui/src/widgets/DropdownButton/dropdownButton.module.scss @@ -67,7 +67,7 @@ position: absolute; right: 6px; top: 14px; - width: 0 + width: 0; } } diff --git a/packages/neuron-ui/src/widgets/MnemonicInput/index.module.scss b/packages/neuron-ui/src/widgets/MnemonicInput/index.module.scss index 716ce0c766..04d920b55e 100644 --- a/packages/neuron-ui/src/widgets/MnemonicInput/index.module.scss +++ b/packages/neuron-ui/src/widgets/MnemonicInput/index.module.scss @@ -1,7 +1,7 @@ .root { width: 624px; background: var(--secondary-background-color); - border: 1px solid #F0F0F0; + border: 1px solid #f0f0f0; border-radius: 8px; display: grid; grid-template-columns: repeat(6, 60px); @@ -25,14 +25,14 @@ & .wordItem { &:focus-within { - color: #00C891; + color: #00c891; } &:not(:focus-within) { &.errorWords { - color: #FF1E1E; + color: #ff1e1e; & > input { - border-bottom: 1px solid #FF1E1E; - color: #FF1E1E; + border-bottom: 1px solid #ff1e1e; + color: #ff1e1e; } } } @@ -56,7 +56,7 @@ padding-bottom: 4px; &:focus { - border-bottom: 1px solid #00C891;; + border-bottom: 1px solid #00c891; } } } diff --git a/packages/neuron-ui/src/widgets/Select/select.module.scss b/packages/neuron-ui/src/widgets/Select/select.module.scss index bfd48b1e9f..87e8e20817 100644 --- a/packages/neuron-ui/src/widgets/Select/select.module.scss +++ b/packages/neuron-ui/src/widgets/Select/select.module.scss @@ -3,7 +3,6 @@ font-size: 0.75rem; } - .control { position: relative; overflow: hidden; @@ -17,7 +16,7 @@ padding: 8px 52px 8px 10px; // transition: all 200ms ease; - &[data-open="true"] { + &[data-open='true'] { border: 1px solid #000; } @@ -37,7 +36,7 @@ position: absolute; right: 10px; top: 14px; - width: 0 + width: 0; } .is-open .arrow { @@ -60,7 +59,7 @@ -webkit-overflow-scrolling: touch; } -.menu .group > .title{ +.menu .group > .title { padding: 8px 10px; color: rgba(51, 51, 51, 1); font-weight: bold; @@ -74,7 +73,7 @@ display: block; padding: 8px 10px; - &[aria-selected="true"] { + &[aria-selected='true'] { background-color: #ccc; } @@ -84,7 +83,7 @@ &:last-child { border-bottom-right-radius: 2px; - border-bottom-left-radius: 2px; + border-bottom-left-radius: 2px; } &:hover { diff --git a/packages/neuron-wallet/tests/block-sync-renderer/indexer-cache-service.intg.test.ts b/packages/neuron-wallet/tests/block-sync-renderer/indexer-cache-service.intg.test.ts index a05f81e755..509c7808f3 100644 --- a/packages/neuron-wallet/tests/block-sync-renderer/indexer-cache-service.intg.test.ts +++ b/packages/neuron-wallet/tests/block-sync-renderer/indexer-cache-service.intg.test.ts @@ -275,21 +275,27 @@ describe('indexer cache service', () => { stubbedCellCollectorConstructor.mockReset() when(stubbedCellCollectorConstructor) - .calledWith(expect.anything(), expect.objectContaining({ - lock: { - ...formattedSingleMultiSignLockScript, - args: formattedSingleMultiSignLockScript.args.slice(0, 42), - }, - argsLen: 28, - })) + .calledWith( + expect.anything(), + expect.objectContaining({ + lock: { + ...formattedSingleMultiSignLockScript, + args: formattedSingleMultiSignLockScript.args.slice(0, 42), + }, + argsLen: 28, + }) + ) .mockReturnValue(fakeCollectorObj) - .calledWith(expect.anything(), expect.objectContaining({ - lock: { - ...formattedChequeLockScript, - args: formattedChequeLockScript.args.slice(0, 42), - }, - argsLen: 40, - })) + .calledWith( + expect.anything(), + expect.objectContaining({ + lock: { + ...formattedChequeLockScript, + args: formattedChequeLockScript.args.slice(0, 42), + }, + argsLen: 40, + }) + ) .mockReturnValue(fakeCollectorObj) newTxHashes = await indexerCacheService.upsertTxHashes() diff --git a/packages/neuron-wallet/tests/controllers/export-debug.test.ts b/packages/neuron-wallet/tests/controllers/export-debug.test.ts index 5fdb6503e6..3d25983003 100644 --- a/packages/neuron-wallet/tests/controllers/export-debug.test.ts +++ b/packages/neuron-wallet/tests/controllers/export-debug.test.ts @@ -78,10 +78,10 @@ jest.mock('../../src/services/light-runner', () => { CKBLightRunner: { getInstance() { return { - logPath: '' + logPath: '', } - } - } + }, + }, } }) diff --git a/packages/neuron-wallet/tests/controllers/sync-api.test.ts b/packages/neuron-wallet/tests/controllers/sync-api.test.ts index efad4951b3..b1eafaf5d8 100644 --- a/packages/neuron-wallet/tests/controllers/sync-api.test.ts +++ b/packages/neuron-wallet/tests/controllers/sync-api.test.ts @@ -51,7 +51,7 @@ jest.mock('undici', () => ({ request: () => jest.fn()(), })) jest.mock('services/multisig', () => ({ - syncMultisigOutput: () => jest.fn() + syncMultisigOutput: () => jest.fn(), })) describe('SyncApiController', () => { @@ -139,7 +139,7 @@ describe('SyncApiController', () => { stubbedNodeGetInstance.mockReturnValue({ get nodeUrl() { return fakeNodeUrl - } + }, }) stubbedGetTipHeader.mockResolvedValue({ timestamp: '180000' }) }) @@ -363,7 +363,7 @@ describe('SyncApiController', () => { stubbedNodeGetInstance.mockReturnValue({ get nodeUrl() { return 'anotherfakeurl' - } + }, }) await sendFakeCacheBlockTipEvent(newFakeState) @@ -473,7 +473,7 @@ describe('SyncApiController', () => { stubbedNodeGetInstance.mockImplementation(() => ({ get nodeUrl() { return 'http://diffurl' - } + }, })) await sendFakeCacheBlockTipEvent(fakeState3) }) diff --git a/packages/neuron-wallet/tests/models/chain/fixtures/tx.json b/packages/neuron-wallet/tests/models/chain/fixtures/tx.json index e30bcb87dc..d92046c62a 100644 --- a/packages/neuron-wallet/tests/models/chain/fixtures/tx.json +++ b/packages/neuron-wallet/tests/models/chain/fixtures/tx.json @@ -48,10 +48,7 @@ "capacity": "0x123057115949" } ], - "outputsData": [ - "0x0000000000000000", - "0x" - ], + "outputsData": ["0x0000000000000000", "0x"], "headerDeps": [], "hash": "0x6df26cc7e3f5fd38a42658f3fb520144a092179b7fd9729dd1ea1f8f2d869745", "version": "0x0", diff --git a/packages/neuron-wallet/tests/models/chain/live-cell.test.ts b/packages/neuron-wallet/tests/models/chain/live-cell.test.ts index ac52ee6359..9385e21de1 100644 --- a/packages/neuron-wallet/tests/models/chain/live-cell.test.ts +++ b/packages/neuron-wallet/tests/models/chain/live-cell.test.ts @@ -1,6 +1,6 @@ import Script, { ScriptHashType } from '../../../src/models/chain/script' import { LumosCell } from '../../../src/block-sync-renderer/sync/connector' -import LiveCell from "../../../src/models/chain/live-cell" +import LiveCell from '../../../src/models/chain/live-cell' describe('LiveCell Test', () => { const INITIAL_DATA = { diff --git a/packages/neuron-wallet/tests/services/ckb-runner.test.ts b/packages/neuron-wallet/tests/services/ckb-runner.test.ts index fd2a07f6f8..6d52f70803 100644 --- a/packages/neuron-wallet/tests/services/ckb-runner.test.ts +++ b/packages/neuron-wallet/tests/services/ckb-runner.test.ts @@ -77,8 +77,8 @@ jest.mock('../../src/services/indexer', () => ({ })) jest.doMock('../../src/block-sync-renderer', () => ({ resetSyncTaskQueue: { - asyncPush: resetSyncTaskQueueAsyncPushMock - } + asyncPush: resetSyncTaskQueueAsyncPushMock, + }, })) const { startCkbNode, @@ -203,7 +203,7 @@ describe('ckb runner', () => { it('runs ckb binary', () => { expect(stubbedSpawn).toHaveBeenCalledWith( expect.stringContaining(path.join('bin', 'ckb')), - ['run', '-C', ckbDataPath, '--indexer', "--assume-valid-target", '0x' + '0'.repeat(64)], + ['run', '-C', ckbDataPath, '--indexer', '--assume-valid-target', '0x' + '0'.repeat(64)], { stdio: ['ignore', 'pipe', 'pipe'] } ) }) diff --git a/packages/neuron-wallet/tests/services/indexer.test.ts b/packages/neuron-wallet/tests/services/indexer.test.ts index 0d8872c9fb..9cf0fcb2e9 100644 --- a/packages/neuron-wallet/tests/services/indexer.test.ts +++ b/packages/neuron-wallet/tests/services/indexer.test.ts @@ -29,7 +29,7 @@ jest.mock('../../src/services/settings', () => { }, get ckbDataPath() { return jest.fn().mockReturnValue('')() - } + }, } } } @@ -40,15 +40,15 @@ jest.mock('../../src/utils/logger', () => ({ })) jest.mock('../../src/models/synced-block-number', () => { - return function() { + return function () { return { - setNextBlock: jest.fn() + setNextBlock: jest.fn(), } } }) jest.mock('../../src/database/chain', () => ({ - clean: () => jest.fn() + clean: () => jest.fn(), })) jest.mock('../../src/services/monitor', () => { @@ -71,8 +71,8 @@ jest.mock('../../src/services/node', () => ({ const resetSyncTaskQueueAsyncPushMock = jest.fn() jest.mock('../../src/block-sync-renderer', () => ({ resetSyncTaskQueue: { - asyncPush: () => resetSyncTaskQueueAsyncPushMock() - } + asyncPush: () => resetSyncTaskQueueAsyncPushMock(), + }, })) describe('test IndexerService', () => { diff --git a/packages/neuron-wallet/tests/services/light-runner.test.ts b/packages/neuron-wallet/tests/services/light-runner.test.ts index f2b1fdf74c..69980d2c1f 100644 --- a/packages/neuron-wallet/tests/services/light-runner.test.ts +++ b/packages/neuron-wallet/tests/services/light-runner.test.ts @@ -50,7 +50,7 @@ jest.doMock('../../src/env', () => ({ get isPackaged() { return isPackagedMock() }, - } + }, })) jest.doMock('../../src/utils/logger', () => ({ @@ -58,27 +58,29 @@ jest.doMock('../../src/utils/logger', () => ({ error: loggerErrorMock, transports: { file: { - getFile: transportsGetFileMock - } - } + getFile: transportsGetFileMock, + }, + }, })) jest.doMock('../../src/services/settings', () => ({ getInstance() { return { - get testnetLightDataPath() { return lightDataPathMock() } + get testnetLightDataPath() { + return lightDataPathMock() + }, } - } + }, })) jest.doMock('../../src/database/chain', () => ({ - clean: cleanMock + clean: cleanMock, })) jest.doMock('../../src/block-sync-renderer', () => ({ resetSyncTaskQueue: { - asyncPush: resetSyncTaskQueueAsyncPushMock - } + asyncPush: resetSyncTaskQueueAsyncPushMock, + }, })) jest.doMock('process', () => ({ @@ -98,7 +100,7 @@ jest.doMock('fs', () => ({ readFileSync: readFileSyncMock, mkdirSync: mkdirSyncMock, writeFileSync: writeFileSyncMock, - createWriteStream: createWriteStreamMock + createWriteStream: createWriteStreamMock, })) jest.doMock('child_process', () => ({ @@ -109,7 +111,7 @@ const { CKBLightRunner } = require('../../src/services/light-runner') describe('test light runner', () => { beforeEach(() => { - transportsGetFileMock.mockReturnValue({ path: ''}) + transportsGetFileMock.mockReturnValue({ path: '' }) createWriteStreamMock.mockReturnValue({ write() {} }) }) afterEach(() => { @@ -167,7 +169,11 @@ describe('test light runner', () => { expect(dirnameMock).toBeCalledTimes(0) expect(getAppPathMock).toBeCalledTimes(0) expect(joinMock).toBeCalledWith(lightRunnerDirpath, '../../bin') - expect(resolveMock).toBeCalledWith('joinpath', `./${CKBLightRunner.getInstance().platform()}`, './ckb-light-client') + expect(resolveMock).toBeCalledWith( + 'joinpath', + `./${CKBLightRunner.getInstance().platform()}`, + './ckb-light-client' + ) CKBLightRunner.getInstance().platform = tmp }) }) @@ -285,13 +291,15 @@ describe('test light runner', () => { await CKBLightRunner.getInstance().stop() }) it('runnerProcess is defined', async () => { - const emitter: EventEmitter & { kill?: Function } = new EventEmitter() + const emitter: EventEmitter & { kill?: () => void } = new EventEmitter() emitter.kill = mockFn CKBLightRunner.getInstance().runnerProcess = emitter - mockFn.mockImplementation(() => { emitter.emit('close') }) + mockFn.mockImplementation(() => { + emitter.emit('close') + }) await CKBLightRunner.getInstance().stop() expect(mockFn).toBeCalledWith() expect(CKBLightRunner.getInstance().runnerProcess).toBeUndefined() }) }) -}) \ No newline at end of file +}) diff --git a/packages/neuron-wallet/tests/utils/ckb-rpc.test.ts b/packages/neuron-wallet/tests/utils/ckb-rpc.test.ts index a1eca58a5f..ae28386620 100644 --- a/packages/neuron-wallet/tests/utils/ckb-rpc.test.ts +++ b/packages/neuron-wallet/tests/utils/ckb-rpc.test.ts @@ -16,4 +16,4 @@ describe('test ckb rpc file', () => { expect(result.node.httpsAgent).toBeDefined() }) }) -}) \ No newline at end of file +}) diff --git a/packages/neuron-wallet/tests/utils/fixtures/worker.js b/packages/neuron-wallet/tests/utils/fixtures/worker.js index 1f4dd2008c..09a2924e68 100644 --- a/packages/neuron-wallet/tests/utils/fixtures/worker.js +++ b/packages/neuron-wallet/tests/utils/fixtures/worker.js @@ -1,9 +1,8 @@ +/* eslint-disable-next-line @typescript-eslint/no-var-requires */ const { expose } = require('./../../../dist/utils/worker') expose({ - doNothing() { - - }, + doNothing() {}, normal() { return 'normal' }, @@ -12,9 +11,9 @@ expose({ setTimeout(() => { resolve('async/await') }, 2000) - }, ) + }) }, args(...args) { return args - } + }, })