diff --git a/web/cashtab/src/components/SignVerifyMsg/__tests__/SignVerifyMsg.test.js b/web/cashtab/src/components/SignVerifyMsg/__tests__/SignVerifyMsg.test.js new file mode 100644 --- /dev/null +++ b/web/cashtab/src/components/SignVerifyMsg/__tests__/SignVerifyMsg.test.js @@ -0,0 +1,97 @@ +import React from 'react'; +import renderer from 'react-test-renderer'; +import { ThemeProvider } from 'styled-components'; +import { theme } from 'assets/styles/theme'; +import { + walletWithoutBalancesMock, + walletWithBalancesMock, + walletWithBalancesAndTokensWithCorrectState, +} from '../../Home/__mocks__/walletAndBalancesMock'; +import SignVerifyMsg from '../SignVerifyMsg'; +import BCHJS from '@psf/bch-js'; +import { BrowserRouter as Router } from 'react-router-dom'; +import { WalletContext } from 'utils/context'; + +beforeEach(() => { + // Mock method not implemented in JSDOM + // See reference at https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom + Object.defineProperty(window, 'matchMedia', { + writable: true, + value: jest.fn().mockImplementation(query => ({ + matches: false, + media: query, + onchange: null, + addListener: jest.fn(), // Deprecated + removeListener: jest.fn(), // Deprecated + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + dispatchEvent: jest.fn(), + })), + }); +}); + +test('Wallet without BCH balance', () => { + const testBCH = new BCHJS(); + const component = renderer.create( + + + + + + + , + ); + let tree = component.toJSON(); + expect(tree).toMatchSnapshot(); +}); + +test('Wallet with BCH balances', () => { + const testBCH = new BCHJS(); + const component = renderer.create( + + + + + + + , + ); + let tree = component.toJSON(); + expect(tree).toMatchSnapshot(); +}); +test('Wallet with BCH balances and tokens and state field', () => { + const testBCH = new BCHJS(); + const component = renderer.create( + + + + + + + , + ); + let tree = component.toJSON(); + expect(tree).toMatchSnapshot(); +}); + +test('Without wallet defined', () => { + const withoutWalletDefinedMock = { + wallet: {}, + balances: { totalBalance: 0 }, + loading: false, + }; + const testBCH = new BCHJS(); + const component = renderer.create( + + + + + + + , + ); + let tree = component.toJSON(); + expect(tree).toMatchSnapshot(); +}); diff --git a/web/cashtab/src/components/SignVerifyMsg/__tests__/__snapshots__/SignVerifyMsg.test.js.snap b/web/cashtab/src/components/SignVerifyMsg/__tests__/__snapshots__/SignVerifyMsg.test.js.snap new file mode 100644 --- /dev/null +++ b/web/cashtab/src/components/SignVerifyMsg/__tests__/__snapshots__/SignVerifyMsg.test.js.snap @@ -0,0 +1,773 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP @generated + +exports[`Wallet with BCH balances 1`] = ` +
+
+
+

+ MigrationTestAlpha +

+ + + edit.svg + + +
+ + +
+
+
+ You currently have 0 + XEC +
+ Deposit some funds to use this feature +
+
+ +
+
+
+
+
+
+ + + +
+ +
+ Sign Message +
+
+
+
+
+
+
+
+
+
+
+ + + +
+ +
+ Verify Message +
+
+
+
+
+
+
+
+`; + +exports[`Wallet with BCH balances and tokens and state field 1`] = ` +
+
+
+

+ MigrationTestAlpha +

+ + + edit.svg + + +
+ + +
+
+
+ + + 0.06 + + XEC + + +
+
+ +
+
+
+
+
+
+ + + +
+ +
+ Sign Message +
+
+
+
+
+
+
+
+
+
+
+ + + +
+ +
+ Verify Message +
+
+
+
+
+
+
+
+`; + +exports[`Wallet without BCH balance 1`] = ` +
+
+
+

+ MigrationTestAlpha +

+ + + edit.svg + + +
+ + +
+
+
+ You currently have 0 + XEC +
+ Deposit some funds to use this feature +
+
+ +
+
+
+
+
+
+ + + +
+ +
+ Sign Message +
+
+
+
+
+
+
+
+
+
+
+ + + +
+ +
+ Verify Message +
+
+
+
+
+
+
+
+`; + +exports[`Without wallet defined 1`] = ` +
+
+
+ + + edit.svg + + +
+ + +
+
+
+ You currently have 0 + XEC +
+ Deposit some funds to use this feature +
+
+ +
+
+
+
+
+
+ + + +
+ +
+ Sign Message +
+
+
+
+
+
+
+
+
+
+
+ + + +
+ +
+ Verify Message +
+
+
+
+
+
+
+
+`;