2021-06-05 08:33:58 +02:00
|
|
|
import sinon from 'sinon';
|
|
|
|
import migration61 from './061';
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
describe('migration #61', () => {
|
2021-06-05 08:33:58 +02:00
|
|
|
let dateStub;
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
beforeEach(() => {
|
2021-06-05 08:33:58 +02:00
|
|
|
dateStub = sinon.stub(Date.prototype, 'getTime').returns(1621580400000);
|
|
|
|
});
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
afterEach(() => {
|
2021-06-05 08:33:58 +02:00
|
|
|
dateStub.restore();
|
|
|
|
});
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
it('should update the version metadata', async () => {
|
2021-06-05 08:33:58 +02:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {
|
|
|
|
version: 60,
|
|
|
|
},
|
|
|
|
data: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration61.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.meta).toStrictEqual({
|
2021-06-05 08:33:58 +02:00
|
|
|
version: 61,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
it('should set recoveryPhraseReminderHasBeenShown to false and recoveryPhraseReminderLastShown to the current time', async () => {
|
2021-06-05 08:33:58 +02:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
AppStateController: {
|
|
|
|
existingProperty: 'foo',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration61.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-06-05 08:33:58 +02:00
|
|
|
AppStateController: {
|
|
|
|
recoveryPhraseReminderHasBeenShown: false,
|
|
|
|
recoveryPhraseReminderLastShown: 1621580400000,
|
|
|
|
existingProperty: 'foo',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
it('should initialize AppStateController if it does not exist', async () => {
|
2021-06-05 08:33:58 +02:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
existingProperty: 'foo',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration61.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-06-05 08:33:58 +02:00
|
|
|
existingProperty: 'foo',
|
|
|
|
AppStateController: {
|
|
|
|
recoveryPhraseReminderHasBeenShown: false,
|
|
|
|
recoveryPhraseReminderLastShown: 1621580400000,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|