You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.7 KiB
64 lines
1.7 KiB
4 years ago
|
import assert from 'assert';
|
||
|
import React from 'react';
|
||
|
import sinon from 'sinon';
|
||
|
import { mount } from 'enzyme';
|
||
4 years ago
|
import UnlockPage from './unlock-page.container';
|
||
5 years ago
|
|
||
5 years ago
|
describe('Unlock Page', function () {
|
||
4 years ago
|
let wrapper;
|
||
5 years ago
|
|
||
|
const props = {
|
||
|
history: {
|
||
|
push: sinon.spy(),
|
||
|
},
|
||
|
isUnlocked: false,
|
||
|
onImport: sinon.spy(),
|
||
|
onRestore: sinon.spy(),
|
||
|
onSubmit: sinon.spy(),
|
||
|
forceUpdateMetamaskState: sinon.spy(),
|
||
|
showOptInModal: sinon.spy(),
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
5 years ago
|
beforeEach(function () {
|
||
4 years ago
|
wrapper = mount(<UnlockPage.WrappedComponent {...props} />, {
|
||
|
context: {
|
||
|
t: (str) => str,
|
||
4 years ago
|
},
|
||
4 years ago
|
});
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
after(function () {
|
||
4 years ago
|
sinon.restore();
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('renders', function () {
|
||
4 years ago
|
assert.strictEqual(wrapper.length, 1);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('changes password and submits', function () {
|
||
4 years ago
|
const passwordField = wrapper.find({ type: 'password', id: 'password' });
|
||
|
const loginButton = wrapper.find({ type: 'submit' }).last();
|
||
5 years ago
|
|
||
4 years ago
|
const event = { target: { value: 'password' } };
|
||
|
assert.strictEqual(wrapper.instance().state.password, '');
|
||
|
passwordField.last().simulate('change', event);
|
||
|
assert.strictEqual(wrapper.instance().state.password, 'password');
|
||
5 years ago
|
|
||
4 years ago
|
loginButton.simulate('click');
|
||
|
assert(props.onSubmit.calledOnce);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('clicks imports seed button', function () {
|
||
4 years ago
|
const importSeedButton = wrapper.find('.unlock-page__link--import');
|
||
5 years ago
|
|
||
4 years ago
|
importSeedButton.simulate('click');
|
||
|
assert(props.onImport.calledOnce);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('clicks restore', function () {
|
||
4 years ago
|
const restoreFromSeedButton = wrapper.find('.unlock-page__link').at(0);
|
||
|
restoreFromSeedButton.simulate('click');
|
||
|
assert(props.onRestore.calledOnce);
|
||
|
});
|
||
|
});
|