1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/app/scripts/migrations/049.test.js

133 lines
3.0 KiB
JavaScript
Raw Normal View History

import { strict as assert } from 'assert';
import migration49 from './049';
2020-12-02 22:41:30 +01:00
describe('migration #49', function () {
it('should update the version metadata', async function () {
const oldStorage = {
meta: {
version: 48,
},
data: {},
};
2020-12-02 22:41:30 +01:00
const newStorage = await migration49.migrate(oldStorage);
2020-12-02 22:41:30 +01:00
assert.deepStrictEqual(newStorage.meta, {
version: 49,
});
});
2020-12-02 22:41:30 +01:00
it('should move metaMetricsId to MetaMetricsController', async function () {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
metaMetricsId: '0xaab',
bar: 'baz',
},
foo: 'bar',
},
};
2020-12-02 22:41:30 +01:00
const newStorage = await migration49.migrate(oldStorage);
2020-12-02 22:41:30 +01:00
assert.deepStrictEqual(newStorage.data, {
PreferencesController: {
bar: 'baz',
},
MetaMetricsController: {
metaMetricsId: '0xaab',
},
foo: 'bar',
});
});
2020-12-02 22:41:30 +01:00
it('should move participateInMetaMetrics to MetaMetricsController', async function () {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
participateInMetaMetrics: false,
bar: 'baz',
},
foo: 'bar',
},
};
2020-12-02 22:41:30 +01:00
const newStorage = await migration49.migrate(oldStorage);
2020-12-02 22:41:30 +01:00
assert.deepStrictEqual(newStorage.data, {
PreferencesController: {
bar: 'baz',
},
MetaMetricsController: {
participateInMetaMetrics: false,
},
foo: 'bar',
});
});
2020-12-02 22:41:30 +01:00
it('should move metaMetricsSendCount to MetaMetricsController', async function () {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
metaMetricsSendCount: 1,
bar: 'baz',
},
foo: 'bar',
},
};
2020-12-02 22:41:30 +01:00
const newStorage = await migration49.migrate(oldStorage);
2020-12-02 22:41:30 +01:00
assert.deepStrictEqual(newStorage.data, {
PreferencesController: {
bar: 'baz',
},
MetaMetricsController: {
metaMetricsSendCount: 1,
},
foo: 'bar',
});
});
2020-12-02 22:41:30 +01:00
it('should move all metaMetrics fields to MetaMetricsController', async function () {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
metaMetricsSendCount: 1,
metaMetricsId: '0xaab',
participateInMetaMetrics: true,
bar: 'baz',
},
foo: 'bar',
},
};
2020-12-02 22:41:30 +01:00
const newStorage = await migration49.migrate(oldStorage);
2020-12-02 22:41:30 +01:00
assert.deepStrictEqual(newStorage.data, {
PreferencesController: {
bar: 'baz',
},
MetaMetricsController: {
metaMetricsSendCount: 1,
metaMetricsId: '0xaab',
participateInMetaMetrics: true,
},
foo: 'bar',
});
});
2020-12-02 22:41:30 +01:00
it('should do nothing if no PreferencesController key', async function () {
const oldStorage = {
meta: {},
data: {
foo: 'bar',
},
};
2020-12-02 22:41:30 +01:00
const newStorage = await migration49.migrate(oldStorage);
2020-12-02 22:41:30 +01:00
assert.deepStrictEqual(newStorage.data, {
foo: 'bar',
});
});
});