1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/ui/pages/onboarding-flow/recovery-phrase/recovery-phrase-chips.test.js
Thomas Huang b14b6ba07d
Recovery phrase chips onboarding unit tests (#18249)
* Recovery phrase chips onboarding unit tests

* Add Snapshot for recovery phrase chips

* Add test for classname hidden check and confirm recovery phrase indices

---------

Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2023-04-20 13:34:58 -05:00

67 lines
1.9 KiB
JavaScript

import React from 'react';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import RecoveryPhraseChips from './recovery-phrase-chips';
describe('Recovery Phrase Chips Component', () => {
const TEST_SEED =
'debris dizzy just program just float decrease vacant alarm reduce speak stadium';
it('should match snapshot', () => {
const props = {
secretRecoveryPhrase: TEST_SEED.split(' '),
};
const { queryByTestId, container } = renderWithProvider(
<RecoveryPhraseChips {...props} />,
);
expect(container).toMatchSnapshot();
const recoveryPhraseChips = queryByTestId('recovery-phrase-chips');
expect(recoveryPhraseChips).not.toHaveClass(
'recovery-phrase__chips--hidden',
);
});
it('should have --hidden class when phrase revealed is false', () => {
const props = {
secretRecoveryPhrase: TEST_SEED.split(' '),
phraseRevealed: false,
};
const { queryByTestId } = renderWithProvider(
<RecoveryPhraseChips {...props} />,
);
const recoveryPhraseChips = queryByTestId('recovery-phrase-chips');
expect(recoveryPhraseChips).toHaveClass('recovery-phrase__chips--hidden');
});
it('should match snapshot of confirm recovery phrase with inputs of indicies to check', () => {
const props = {
secretRecoveryPhrase: TEST_SEED.split(' '),
indicesToCheck: [1, 5, 10],
confirmPhase: true,
inputValue: {},
};
const { container } = renderWithProvider(
<RecoveryPhraseChips {...props} />,
);
expect(container).toMatchSnapshot();
});
it('should have seed phrase as proper element length', () => {
const props = {
secretRecoveryPhrase: TEST_SEED.split(' '),
};
const { queryAllByTestId } = renderWithProvider(
<RecoveryPhraseChips {...props} />,
);
expect(queryAllByTestId(/recovery-phrase-chip-/u)).toHaveLength(12);
});
});