2021-03-16 22:00:08 +01:00
|
|
|
import migration49 from './049';
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('migration #49', () => {
|
|
|
|
it('should update the version metadata', async () => {
|
2020-12-02 22:41:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {
|
|
|
|
version: 48,
|
|
|
|
},
|
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration49.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.meta).toStrictEqual({
|
2020-12-02 22:41:30 +01:00
|
|
|
version: 49,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should move metaMetricsId to MetaMetricsController', async () => {
|
2020-12-02 22:41:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
metaMetricsId: '0xaab',
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration49.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2020-12-02 22:41:30 +01:00
|
|
|
PreferencesController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
MetaMetricsController: {
|
|
|
|
metaMetricsId: '0xaab',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should move participateInMetaMetrics to MetaMetricsController', async () => {
|
2020-12-02 22:41:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
participateInMetaMetrics: false,
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration49.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2020-12-02 22:41:30 +01:00
|
|
|
PreferencesController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
MetaMetricsController: {
|
|
|
|
participateInMetaMetrics: false,
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should move metaMetricsSendCount to MetaMetricsController', async () => {
|
2020-12-02 22:41:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
metaMetricsSendCount: 1,
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration49.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2020-12-02 22:41:30 +01:00
|
|
|
PreferencesController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
MetaMetricsController: {
|
|
|
|
metaMetricsSendCount: 1,
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should move all metaMetrics fields to MetaMetricsController', async () => {
|
2020-12-02 22:41:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
metaMetricsSendCount: 1,
|
|
|
|
metaMetricsId: '0xaab',
|
|
|
|
participateInMetaMetrics: true,
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration49.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2020-12-02 22:41:30 +01:00
|
|
|
PreferencesController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
MetaMetricsController: {
|
|
|
|
metaMetricsSendCount: 1,
|
|
|
|
metaMetricsId: '0xaab',
|
|
|
|
participateInMetaMetrics: true,
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should do nothing if no PreferencesController key', async () => {
|
2020-12-02 22:41:30 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-12-02 22:41:30 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration49.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2020-12-02 22:41:30 +01:00
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|