2021-03-16 22:00:08 +01:00
|
|
|
import migration43 from './043';
|
2020-04-24 05:23:28 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('migration #43', () => {
|
|
|
|
it('should update the version metadata', async () => {
|
2020-04-24 05:23:28 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {
|
|
|
|
version: 42,
|
2020-04-24 05:23:28 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-04-24 05:23:28 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration43.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.meta).toStrictEqual({
|
2020-11-03 00:41:28 +01:00
|
|
|
version: 43,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-04-24 05:23:28 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should delete currentAccountTab state', async () => {
|
2020-04-24 05:23:28 +02:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
currentAccountTab: 'history',
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-04-24 05:23:28 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration43.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2020-04-24 05:23:28 +02:00
|
|
|
PreferencesController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-04-24 05:23:28 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should do nothing if currentAccountTab state does not exist', async () => {
|
2020-04-24 05:23:28 +02:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-04-24 05:23:28 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration43.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(oldStorage.data).toStrictEqual(newStorage.data);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|