You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.8 KiB
110 lines
2.8 KiB
4 years ago
|
import { strict as assert } from 'assert';
|
||
4 years ago
|
import migration47 from './047';
|
||
4 years ago
|
|
||
|
describe('migration #47', function () {
|
||
|
it('should update the version metadata', async function () {
|
||
|
const oldStorage = {
|
||
4 years ago
|
meta: {
|
||
|
version: 46,
|
||
4 years ago
|
},
|
||
4 years ago
|
data: {},
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
const newStorage = await migration47.migrate(oldStorage);
|
||
4 years ago
|
assert.deepEqual(newStorage.meta, {
|
||
4 years ago
|
version: 47,
|
||
4 years ago
|
});
|
||
|
});
|
||
4 years ago
|
|
||
|
it('should stringify transactions metamaskNetworkId values', async function () {
|
||
|
const oldStorage = {
|
||
|
meta: {},
|
||
|
data: {
|
||
4 years ago
|
TransactionController: {
|
||
4 years ago
|
transactions: [
|
||
|
{ foo: 'bar', metamaskNetworkId: 2 },
|
||
|
{ foo: 'bar' },
|
||
|
{ foo: 'bar', metamaskNetworkId: 0 },
|
||
|
{ foo: 'bar', metamaskNetworkId: 42 },
|
||
|
],
|
||
|
},
|
||
|
foo: 'bar',
|
||
|
},
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
const newStorage = await migration47.migrate(oldStorage);
|
||
4 years ago
|
assert.deepEqual(newStorage.data, {
|
||
4 years ago
|
TransactionController: {
|
||
4 years ago
|
transactions: [
|
||
|
{ foo: 'bar', metamaskNetworkId: '2' },
|
||
|
{ foo: 'bar' },
|
||
|
{ foo: 'bar', metamaskNetworkId: '0' },
|
||
|
{ foo: 'bar', metamaskNetworkId: '42' },
|
||
|
],
|
||
|
},
|
||
|
foo: 'bar',
|
||
4 years ago
|
});
|
||
|
});
|
||
4 years ago
|
|
||
|
it('should do nothing if transactions metamaskNetworkId values are already strings', async function () {
|
||
|
const oldStorage = {
|
||
|
meta: {},
|
||
|
data: {
|
||
4 years ago
|
TransactionController: {
|
||
4 years ago
|
transactions: [
|
||
|
{ foo: 'bar', metamaskNetworkId: '2' },
|
||
|
{ foo: 'bar' },
|
||
|
{ foo: 'bar', metamaskNetworkId: '0' },
|
||
|
{ foo: 'bar', metamaskNetworkId: '42' },
|
||
|
],
|
||
|
},
|
||
|
foo: 'bar',
|
||
|
},
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
const newStorage = await migration47.migrate(oldStorage);
|
||
|
assert.deepEqual(oldStorage.data, newStorage.data);
|
||
|
});
|
||
4 years ago
|
|
||
|
it('should do nothing if transactions state does not exist', async function () {
|
||
|
const oldStorage = {
|
||
|
meta: {},
|
||
|
data: {
|
||
4 years ago
|
TransactionController: {
|
||
4 years ago
|
bar: 'baz',
|
||
|
},
|
||
|
foo: 'bar',
|
||
|
},
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
const newStorage = await migration47.migrate(oldStorage);
|
||
|
assert.deepEqual(oldStorage.data, newStorage.data);
|
||
|
});
|
||
4 years ago
|
|
||
|
it('should do nothing if transactions state is empty', async function () {
|
||
|
const oldStorage = {
|
||
|
meta: {},
|
||
|
data: {
|
||
4 years ago
|
TransactionController: {
|
||
4 years ago
|
transactions: [],
|
||
|
bar: 'baz',
|
||
|
},
|
||
|
foo: 'bar',
|
||
|
},
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
const newStorage = await migration47.migrate(oldStorage);
|
||
|
assert.deepEqual(oldStorage.data, newStorage.data);
|
||
|
});
|
||
4 years ago
|
|
||
|
it('should do nothing if state is empty', async function () {
|
||
|
const oldStorage = {
|
||
|
meta: {},
|
||
|
data: {},
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
const newStorage = await migration47.migrate(oldStorage);
|
||
|
assert.deepEqual(oldStorage.data, newStorage.data);
|
||
|
});
|
||
|
});
|