mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
a5dcc60697
* 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
109 lines
2.6 KiB
JavaScript
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' },
|
|
});
|
|
});
|
|
});
|