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/065.test.js
Alex Donesky 71f91568db
Migrate completedOnboarding and firstTimeFlowType state into onboardingController (#12356)
* migrate completedOnboarding state into onboardingController

* migrate firstTimeFlowType state from preferencesController to onboardingController
2021-10-15 13:52:52 -05:00

146 lines
3.5 KiB
JavaScript

import migration65 from './065';
describe('migration #65', () => {
it('should update the version metadata', async () => {
const oldStorage = {
meta: {
version: 64,
},
data: {},
};
const newStorage = await migration65.migrate(oldStorage);
expect(newStorage.meta).toStrictEqual({
version: 65,
});
});
it('should move completedOnboarding from PreferencesController to OnboardingController when completedOnboarding is true', async () => {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
completedOnboarding: true,
bar: 'baz',
},
OnboardingController: {
foo: 'bar',
},
},
};
const newStorage = await migration65.migrate(oldStorage);
expect(newStorage.data).toStrictEqual({
PreferencesController: {
bar: 'baz',
},
OnboardingController: {
completedOnboarding: true,
foo: 'bar',
},
});
});
it('should move completedOnboarding from PreferencesController to OnboardingController when completedOnboarding is false', async () => {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
completedOnboarding: false,
bar: 'baz',
},
OnboardingController: {
foo: 'bar',
},
},
};
const newStorage = await migration65.migrate(oldStorage);
expect(newStorage.data).toStrictEqual({
PreferencesController: {
bar: 'baz',
},
OnboardingController: {
completedOnboarding: false,
foo: 'bar',
},
});
});
it('should move firstTimeFlowType from PreferencesController to OnboardingController when firstTimeFlowType is truthy', async () => {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
firstTimeFlowType: 'create',
bar: 'baz',
},
OnboardingController: {
foo: 'bar',
},
},
};
const newStorage = await migration65.migrate(oldStorage);
expect(newStorage.data).toStrictEqual({
PreferencesController: {
bar: 'baz',
},
OnboardingController: {
firstTimeFlowType: 'create',
foo: 'bar',
},
});
});
it('should move firstTimeFlowType from PreferencesController to OnboardingController when firstTimeFlowType is falsy', async () => {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
firstTimeFlowType: null,
bar: 'baz',
},
OnboardingController: {
foo: 'bar',
},
},
};
const newStorage = await migration65.migrate(oldStorage);
expect(newStorage.data).toStrictEqual({
PreferencesController: {
bar: 'baz',
},
OnboardingController: {
firstTimeFlowType: null,
foo: 'bar',
},
});
});
it('should not modify PreferencesController or OnboardingController when completedOnboarding and firstTimeFlowType are undefined', async () => {
const oldStorage = {
meta: {},
data: {
PreferencesController: {
bar: 'baz',
},
OnboardingController: {
foo: 'bar',
},
},
};
const newStorage = await migration65.migrate(oldStorage);
expect(newStorage.data).toStrictEqual({
PreferencesController: {
bar: 'baz',
},
OnboardingController: {
foo: 'bar',
},
});
});
});