2021-03-16 22:00:08 +01:00
|
|
|
import migration36 from './036';
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('migration #36', () => {
|
|
|
|
it('should update the version metadata', async () => {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {
|
|
|
|
version: 35,
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration36.migrate(oldStorage);
|
|
|
|
expect(newStorage.meta.version).toStrictEqual(36);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should remove privacyMode if featureFlags.privacyMode was false', async () => {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: false,
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration36.migrate(oldStorage);
|
|
|
|
expect(newStorage.data.PreferencesController).toStrictEqual({
|
|
|
|
featureFlags: {},
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should remove privacyMode if featureFlags.privacyMode was true', async () => {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration36.migrate(oldStorage);
|
|
|
|
expect(newStorage.data.PreferencesController).toStrictEqual({
|
|
|
|
featureFlags: {},
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should NOT change any state if privacyMode does not exist', async () => {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
migratedPrivacyMode: true,
|
|
|
|
featureFlags: {},
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration36.migrate(oldStorage);
|
|
|
|
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should NOT change any state if PreferencesController is missing', async () => {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration36.migrate(oldStorage);
|
|
|
|
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should NOT change any state if featureFlags is missing', async () => {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {},
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
const newStorage = await migration36.migrate(oldStorage);
|
|
|
|
expect(newStorage.data).toStrictEqual(oldStorage.data);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|