1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 23:58:06 +01:00
metamask-extension/app/scripts/migrations/078.test.js
Dan J Miller a5dcc60697
Change migration 78 version to 79, 79 to 80 and 80 to 78 (so that the… (#17980)
* Change migration 78 version to 79, 79 to 80 and 80 to 78 (so that the new 78 can be picked into an RC)

* Update migration imports
2023-03-06 10:06:01 -03:30

109 lines
2.6 KiB
JavaScript

import { migrate, version } from './078';
describe('migration #78', () => {
it('updates the version metadata', async () => {
const oldStorage = {
meta: {
version: 77,
},
data: {},
};
const newStorage = await migrate(oldStorage);
expect(newStorage.meta).toStrictEqual({
version,
});
});
it('does not change the state if the phishing controller state does not exist', async () => {
const oldStorage = {
meta: {
version: 77,
},
data: { test: '123' },
};
const newStorage = await migrate(oldStorage);
expect(newStorage.data).toStrictEqual(oldStorage.data);
});
const nonObjects = [undefined, null, 'test', 1, ['test']];
for (const invalidState of nonObjects) {
it(`does not change the state if the phishing controller state is ${invalidState}`, async () => {
const oldStorage = {
meta: {
version: 77,
},
data: { PhishingController: invalidState },
};
const newStorage = await migrate(oldStorage);
expect(newStorage.data).toStrictEqual(oldStorage.data);
});
}
it('does not change the state if the phishing controller state does not include "phishing" or "lastFetched" properties', async () => {
const oldStorage = {
meta: {
version: 77,
},
data: { PhishingController: { test: '123' } },
};
const newStorage = await migrate(oldStorage);
expect(newStorage.data).toStrictEqual(oldStorage.data);
});
it('deletes the "phishing" property', async () => {
const oldStorage = {
meta: {
version: 77,
},
data: { PhishingController: { test: '123', phishing: [] } },
};
const newStorage = await migrate(oldStorage);
expect(newStorage.data).toStrictEqual({
PhishingController: { test: '123' },
});
});
it('deletes the "lastFetched" property', async () => {
const oldStorage = {
meta: {
version: 77,
},
data: { PhishingController: { test: '123', lastFetched: 100 } },
};
const newStorage = await migrate(oldStorage);
expect(newStorage.data).toStrictEqual({
PhishingController: { test: '123' },
});
});
it('deletes the "phishing" and "lastFetched" properties', async () => {
const oldStorage = {
meta: {
version: 77,
},
data: {
PhishingController: { test: '123', lastFetched: 100, phishing: [] },
},
};
const newStorage = await migrate(oldStorage);
expect(newStorage.data).toStrictEqual({
PhishingController: { test: '123' },
});
});
});