2021-03-16 22:00:08 +01:00
|
|
|
import migration41 from './041';
|
2020-02-27 05:49:59 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('migration #41', () => {
|
|
|
|
it('should update the version metadata', async () => {
|
2020-02-27 05:49:59 +01:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {
|
|
|
|
version: 40,
|
2020-02-27 05:49:59 +01:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-02-27 05:49:59 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration41.migrate(oldStorage);
|
|
|
|
expect(newStorage.meta.version).toStrictEqual(41);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-02-27 05:49:59 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should rename autoLogoutTimeLimit storage key', async () => {
|
2020-02-27 05:49:59 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
preferences: {
|
|
|
|
autoLogoutTimeLimit: 42,
|
|
|
|
fizz: 'buzz',
|
|
|
|
},
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-02-27 05:49:59 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration41.migrate(oldStorage);
|
|
|
|
expect(newStorage.data).toStrictEqual({
|
|
|
|
PreferencesController: {
|
|
|
|
preferences: {
|
|
|
|
autoLockTimeLimit: 42,
|
|
|
|
fizz: 'buzz',
|
|
|
|
},
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-02-27 05:49:59 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should do nothing if no PreferencesController key', async () => {
|
2020-02-27 05:49:59 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-02-27 05:49:59 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration41.migrate(oldStorage);
|
|
|
|
expect(newStorage.data).toStrictEqual({
|
|
|
|
foo: 'bar',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-02-27 05:49:59 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should do nothing if no preferences key', async () => {
|
2020-02-27 05:49:59 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-02-27 05:49:59 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration41.migrate(oldStorage);
|
|
|
|
expect(newStorage.data).toStrictEqual({
|
|
|
|
PreferencesController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|