Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
binarybaron committed Jun 12, 2023
1 parent 4168d6f commit 8cc76ba
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/__tests__/store/electrumSlice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import reducer, {
} from '../../store/features/electrumSlice';

test('should return the initial state', () => {
expect(reducer(undefined, {} as AnyAction)).toEqual([]);
expect(reducer(undefined, {} as AnyAction)).toEqual({
txs: [],
connection: null,
});
});

test('should set the electrum list', () => {
Expand All @@ -20,7 +23,7 @@ test('should set the electrum list', () => {
},
};

expect(reducer([], transactionsStatusChanged([mockTx]))).toStrictEqual([
mockTx,
]);
expect(
reducer({ connection: null, txs: [] }, transactionsStatusChanged([mockTx]))
).toStrictEqual({ txs: [mockTx], connection: null });
});
17 changes: 15 additions & 2 deletions src/__tests__/store/listSellersSlice.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { TextEncoder, TextDecoder } from 'util';

import { AnyAction } from '@reduxjs/toolkit';
import reducer, {
setRegistryProviders,
} from '../../store/features/providersSlice';
import { ExtendedProviderStatus } from '../../models/apiModel';

Object.assign(global, { TextDecoder, TextEncoder });

const exampleTestnetProvider: ExtendedProviderStatus = {
multiAddr: '/dnsaddr/t.xmr.example',
peerId: '12394294389438924',
Expand Down Expand Up @@ -58,9 +62,10 @@ describe('testnet', () => {
initialState,
setRegistryProviders([exampleMainnetProvider, exampleTestnetProvider])
)
).toContainEqual({
).toMatchObject({
registry: {
providers: [exampleTestnetProvider],
failedReconnectAttemptsSinceLastSuccess: 0,
},
selectedProvider: exampleTestnetProvider,
});
Expand All @@ -78,9 +83,17 @@ describe('mainnet', () => {
initialState,
setRegistryProviders([exampleMainnetProvider, exampleTestnetProvider])
)
).toEqual({
).toMatchObject({
registry: {
providers: [exampleMainnetProvider],
failedReconnectAttemptsSinceLastSuccess: 0,
},
rendezvous: {
providers: [],
processRunning: false,
exitCode: null,
stdOut: '',
logs: [],
},
selectedProvider: exampleMainnetProvider,
});
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/pages/help/ElectrumInfoBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import InfoBox from '../../modal/swap/InfoBox';
import { Typography } from '@material-ui/core';
import InfoBox from '../../modal/swap/InfoBox';
import BitcoinIcon from '../../icons/BitcoinIcon';
import { useAppSelector } from '../../../../store/hooks';

Expand All @@ -11,7 +11,7 @@ export default function ElectrumInfoBox() {

return (
<InfoBox
title={'Bitcoin Electrum Server'}
title="Bitcoin Electrum Server"
mainContent={
<Typography variant="subtitle2">
The GUI connects to a Bitcoin Electrum Server to retrieve Blockchain
Expand Down
2 changes: 1 addition & 1 deletion src/store/features/providersSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const providersSlice = createSlice({
slice.selectedProvider = selectNewSelectedProvider(slice);
},
increaseFailedRegistryReconnectAttemptsSinceLastSuccess(slice) {
slice.registry.failedReconnectAttemptsSinceLastSuccess++;
slice.registry.failedReconnectAttemptsSinceLastSuccess += 1;
},
setSelectedProvider(
slice,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/multiAddrUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Multiaddr } from 'multiaddr';
import { ExtendedProviderStatus, Provider } from '../models/apiModel';
import semver from 'semver';
import { ExtendedProviderStatus, Provider } from '../models/apiModel';
import { isTestnet } from '../store/config';

const MIN_ASB_VERSION = '0.12.0';
Expand Down

0 comments on commit 8cc76ba

Please sign in to comment.