Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/helpers/__tests__/index.test.js
// Copyright (c) 2023-2024 The Bitcoin developers | // Copyright (c) 2023-2024 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
import { | import { | ||||
isMobile, | isMobile, | ||||
getUserLocale, | getUserLocale, | ||||
cashtabCacheToJSON, | cashtabCacheToJSON, | ||||
storedCashtabCacheToMap, | storedCashtabCacheToMap, | ||||
cashtabWalletFromJSON, | |||||
cashtabWalletToJSON, | |||||
cashtabWalletsFromJSON, | |||||
cashtabWalletsToJSON, | |||||
} from 'helpers'; | } from 'helpers'; | ||||
import vectors from 'helpers/fixtures/vectors'; | import vectors from 'helpers/fixtures/vectors'; | ||||
describe('Cashtab helper functions', () => { | describe('Cashtab helper functions', () => { | ||||
describe('Detect mobile or desktop devices', () => { | describe('Detect mobile or desktop devices', () => { | ||||
const { expectedReturns } = vectors.isMobile; | const { expectedReturns } = vectors.isMobile; | ||||
expectedReturns.forEach(expectedReturn => { | expectedReturns.forEach(expectedReturn => { | ||||
Show All 15 Lines | describe('Cashtab helper functions', () => { | ||||
}); | }); | ||||
describe('Converts cashtabCache to and from JSON for storage and in-app use', () => { | describe('Converts cashtabCache to and from JSON for storage and in-app use', () => { | ||||
const { expectedReturns } = vectors.cashtabCacheToJSON; | const { expectedReturns } = vectors.cashtabCacheToJSON; | ||||
expectedReturns.forEach(expectedReturn => { | expectedReturns.forEach(expectedReturn => { | ||||
const { description, cashtabCache, cashtabCacheJson } = | const { description, cashtabCache, cashtabCacheJson } = | ||||
expectedReturn; | expectedReturn; | ||||
it(`cashtabCacheToJSON and storedCashtabCacheToMap: ${description}`, () => { | it(`cashtabCacheToJSON and storedCashtabCacheToMap: ${description}`, () => { | ||||
expect(cashtabCacheToJSON(cashtabCache)).toStrictEqual( | expect(cashtabCacheToJSON(cashtabCache)).toEqual( | ||||
cashtabCacheJson, | cashtabCacheJson, | ||||
); | ); | ||||
expect(storedCashtabCacheToMap(cashtabCacheJson)).toStrictEqual( | expect(storedCashtabCacheToMap(cashtabCacheJson)).toEqual( | ||||
cashtabCache, | cashtabCache, | ||||
); | ); | ||||
}); | }); | ||||
}); | }); | ||||
}); | }); | ||||
describe('Converts cashtabWallet to and from JSON for storage and in-app use', () => { | |||||
const { expectedReturns } = vectors.cashtabWalletToJSON; | |||||
expectedReturns.forEach(expectedReturn => { | |||||
const { description, cashtabWallet, cashtabWalletJSON } = | |||||
expectedReturn; | |||||
it(`cashtabWalletToJSON and cashtabWalletFromJSON: ${description}`, () => { | |||||
expect(cashtabWalletToJSON(cashtabWallet)).toStrictEqual( | |||||
cashtabWalletJSON, | |||||
); | |||||
expect(cashtabWalletFromJSON(cashtabWalletJSON)).toStrictEqual( | |||||
cashtabWallet, | |||||
); | |||||
}); | |||||
}); | |||||
}); | |||||
describe('Converts cashtabWallets (array) to and from JSON for storage and in-app use', () => { | |||||
const { expectedReturns } = vectors.cashtabWalletsToJSON; | |||||
expectedReturns.forEach(expectedReturn => { | |||||
const { description, cashtabWallets, cashtabWalletsJSON } = | |||||
expectedReturn; | |||||
it(`cashtabWalletsToJSON and cashtabWalletsFromJSON: ${description}`, () => { | |||||
expect(cashtabWalletsToJSON(cashtabWallets)).toStrictEqual( | |||||
cashtabWalletsJSON, | |||||
); | |||||
expect( | |||||
cashtabWalletsFromJSON(cashtabWalletsJSON), | |||||
).toStrictEqual(cashtabWallets); | |||||
}); | |||||
}); | |||||
}); | |||||
}); | }); |