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.
37 lines
979 B
37 lines
979 B
4 years ago
|
import React from 'react';
|
||
|
import sinon from 'sinon';
|
||
4 years ago
|
import { mountWithRouter } from '../../../test/lib/render-helpers';
|
||
4 years ago
|
import Lock from './lock.container';
|
||
4 years ago
|
|
||
4 years ago
|
describe('Lock', () => {
|
||
|
it('replaces history with default route when isUnlocked false', () => {
|
||
4 years ago
|
const props = {
|
||
|
isUnlocked: false,
|
||
|
history: {
|
||
|
replace: sinon.spy(),
|
||
|
},
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
mountWithRouter(<Lock.WrappedComponent {...props} />);
|
||
4 years ago
|
|
||
4 years ago
|
expect(props.history.replace.getCall(0).args[0]).toStrictEqual('/');
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('locks and pushes history with default route when isUnlocked true', async () => {
|
||
4 years ago
|
const props = {
|
||
|
isUnlocked: true,
|
||
|
lockMetamask: sinon.stub(),
|
||
|
history: {
|
||
|
push: sinon.spy(),
|
||
|
},
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
props.lockMetamask.resolves();
|
||
4 years ago
|
|
||
4 years ago
|
mountWithRouter(<Lock.WrappedComponent {...props} />);
|
||
4 years ago
|
|
||
4 years ago
|
expect(await props.lockMetamask.calledOnce).toStrictEqual(true);
|
||
|
expect(props.history.push.getCall(0).args[0]).toStrictEqual('/');
|
||
4 years ago
|
});
|
||
|
});
|