2021-06-25 00:37:44 +02:00
|
|
|
import migration62 from './062';
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
describe('migration #62', () => {
|
|
|
|
it('should update the version metadata', async () => {
|
2021-06-25 00:37:44 +02:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {
|
|
|
|
version: 61,
|
|
|
|
},
|
|
|
|
data: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration62.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.meta).toStrictEqual({
|
2021-06-25 00:37:44 +02:00
|
|
|
version: 62,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
it('should remove metaMetricsSendCount from MetaMetricsController', async () => {
|
2021-06-25 00:37:44 +02:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
MetaMetricsController: {
|
|
|
|
metaMetricsSendCount: 1,
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration62.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-06-25 00:37:44 +02:00
|
|
|
MetaMetricsController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
it('should remove metaMetricsSendCount from MetaMetricsController (falsey but defined)', async () => {
|
2021-06-25 00:37:44 +02:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
MetaMetricsController: {
|
|
|
|
metaMetricsSendCount: 0,
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration62.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-06-25 00:37:44 +02:00
|
|
|
MetaMetricsController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-22 17:15:40 +02:00
|
|
|
it('should not modify MetaMetricsController when metaMetricsSendCount is undefined', async () => {
|
2021-06-25 00:37:44 +02:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
MetaMetricsController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration62.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-06-25 00:37:44 +02:00
|
|
|
MetaMetricsController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|