2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
2022-08-08 22:28:49 +02:00
|
|
|
import { renderWithProvider } from '../../../test/lib/render-helpers';
|
|
|
|
import Lock from './lock.component';
|
2020-11-09 14:50:24 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Lock', () => {
|
|
|
|
it('replaces history with default route when isUnlocked false', () => {
|
2020-11-09 14:50:24 +01:00
|
|
|
const props = {
|
|
|
|
isUnlocked: false,
|
|
|
|
history: {
|
|
|
|
replace: sinon.spy(),
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-11-09 14:50:24 +01:00
|
|
|
|
2022-08-08 22:28:49 +02:00
|
|
|
renderWithProvider(<Lock {...props} />);
|
2020-11-09 14:50:24 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.history.replace.getCall(0).args[0]).toStrictEqual('/');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-09 14:50:24 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('locks and pushes history with default route when isUnlocked true', async () => {
|
2020-11-09 14:50:24 +01:00
|
|
|
const props = {
|
|
|
|
isUnlocked: true,
|
|
|
|
lockMetamask: sinon.stub(),
|
|
|
|
history: {
|
|
|
|
push: sinon.spy(),
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-11-09 14:50:24 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
props.lockMetamask.resolves();
|
2020-11-09 14:50:24 +01:00
|
|
|
|
2022-08-08 22:28:49 +02:00
|
|
|
renderWithProvider(<Lock {...props} />);
|
2020-11-09 14:50:24 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(await props.lockMetamask.calledOnce).toStrictEqual(true);
|
|
|
|
expect(props.history.push.getCall(0).args[0]).toStrictEqual('/');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|