1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/app/scripts/migrations/028.test.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

import firstTimeState from '../first-time-state';
import migration28 from './028';
2018-08-09 22:41:16 +02:00
const oldStorage = {
2020-11-03 00:41:28 +01:00
meta: {},
data: {
PreferencesController: {
tokens: [
{ address: '0xa', symbol: 'A', decimals: 4 },
{ address: '0xb', symbol: 'B', decimals: 4 },
],
identities: {
2018-08-09 22:41:16 +02:00
'0x6d14': {},
'0x3695': {},
},
},
},
};
2018-08-09 22:41:16 +02:00
describe('migration #28', () => {
it('should add corresponding tokens to accountTokens', async () => {
const newStorage = await migration28.migrate(oldStorage);
2018-08-09 22:41:16 +02:00
const newTokens = newStorage.data.PreferencesController.tokens;
const newAccountTokens =
newStorage.data.PreferencesController.accountTokens;
const testTokens = [
{ address: '0xa', symbol: 'A', decimals: 4 },
{ address: '0xb', symbol: 'B', decimals: 4 },
];
expect(newTokens).toHaveLength(0);
expect(newAccountTokens['0x6d14'].mainnet).toHaveLength(2);
expect(newAccountTokens['0x3695'].mainnet).toHaveLength(2);
expect(Object.keys(newAccountTokens)).toHaveLength(2);
expect(newAccountTokens['0x6d14'].mainnet).toStrictEqual(testTokens);
expect(newAccountTokens['0x3695'].mainnet).toStrictEqual(testTokens);
});
2018-08-09 22:41:16 +02:00
it('should successfully migrate first time state', async () => {
const migratedData = await migration28.migrate({
meta: {},
data: firstTimeState,
});
expect(migratedData.meta.version).toStrictEqual(migration28.version);
});
});