1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/app/scripts/migrations/035.test.js
Thomas Huang e78e82205a
Jestify migrations/ (#12106)
* Jestify migrations/

* Lint exclude migrations from mocha config, and add inclusion to jest config

* Add migration tests to jest config

* Exclude/ignore migration tests

* Set process.env.IN_TEST to true when running tests locally
2021-09-21 09:28:13 -07:00

77 lines
1.9 KiB
JavaScript

import migration35 from './035';
describe('migration #35', () => {
it('should update the version metadata', async () => {
const oldStorage = {
meta: {
version: 34,
},
data: {},
};
const newStorage = await migration35.migrate(oldStorage);
expect(newStorage.meta.version).toStrictEqual(35);
});
it('should delete seedWords', async () => {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
seedWords: 'seed words',
},
},
};
const newStorage = await migration35.migrate(oldStorage);
expect(newStorage.data.PreferencesController).toStrictEqual({});
});
it('should delete falsy seedWords', async () => {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
seedWords: '',
},
},
};
const newStorage = await migration35.migrate(oldStorage);
expect(newStorage.data.PreferencesController).toStrictEqual({});
});
it('should leave state without seedWords unchanged', async () => {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
frequentRpcListDetail: [],
accountTokens: {},
assetImages: {},
tokens: [],
suggestedTokens: {},
useBlockie: false,
knownMethodData: {},
participateInMetaMetrics: null,
firstTimeFlowType: null,
currentLocale: 'en',
identities: {},
lostIdentities: {},
forgottenPassword: false,
preferences: {
useNativeCurrencyAsPrimaryCurrency: true,
},
completedOnboarding: false,
migratedPrivacyMode: false,
metaMetricsId: null,
metaMetricsSendCount: 0,
},
},
};
const newStorage = await migration35.migrate(oldStorage);
expect(newStorage.data).toStrictEqual(oldStorage.data);
});
});