mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
4f66dc948f
The controllers package has been updated to v33. The only breaking change in this release was to rename the term "collectible" to "NFT" wherever it appeared in the API. Changes in this PR have been kept minimal; additional renaming can be done in separate PRs. This PR only updates the controller names, controller state, controller methods, and any direct references to these things. NFTs are still called "collectibles" in most places.
144 lines
3.1 KiB
JavaScript
144 lines
3.1 KiB
JavaScript
import migration76 from './076';
|
|
|
|
describe('migration #76', () => {
|
|
it('should update the version metadata', async () => {
|
|
const oldStorage = {
|
|
meta: {
|
|
version: 75,
|
|
},
|
|
data: {},
|
|
};
|
|
|
|
const newStorage = await migration76.migrate(oldStorage);
|
|
expect(newStorage.meta).toStrictEqual({
|
|
version: 76,
|
|
});
|
|
});
|
|
|
|
it('should migrate known controller state properties', async () => {
|
|
const oldStorage = {
|
|
meta: {
|
|
version: 75,
|
|
},
|
|
data: {
|
|
CollectiblesController: {
|
|
allCollectibleContracts: 'foo',
|
|
allCollectibles: 'bar',
|
|
ignoredCollectibles: 'baz',
|
|
},
|
|
PreferencesController: {
|
|
useCollectibleDetection: 'foobar',
|
|
},
|
|
},
|
|
};
|
|
|
|
const newStorage = await migration76.migrate(oldStorage);
|
|
expect(newStorage).toStrictEqual({
|
|
meta: {
|
|
version: 76,
|
|
},
|
|
data: {
|
|
NftController: {
|
|
allNftContracts: 'foo',
|
|
allNfts: 'bar',
|
|
ignoredNfts: 'baz',
|
|
},
|
|
PreferencesController: {
|
|
useNftDetection: 'foobar',
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it('should migrate unknown controller state properties', async () => {
|
|
const oldStorage = {
|
|
meta: {
|
|
version: 75,
|
|
},
|
|
data: {
|
|
CollectiblesController: {
|
|
allCollectibleContracts: 'foo',
|
|
allCollectibles: 'bar',
|
|
ignoredCollectibles: 'baz',
|
|
extra: 'extra',
|
|
},
|
|
PreferencesController: {
|
|
extra: 'extra',
|
|
useCollectibleDetection: 'foobar',
|
|
},
|
|
},
|
|
};
|
|
|
|
const newStorage = await migration76.migrate(oldStorage);
|
|
expect(newStorage).toStrictEqual({
|
|
meta: {
|
|
version: 76,
|
|
},
|
|
data: {
|
|
NftController: {
|
|
allNftContracts: 'foo',
|
|
allNfts: 'bar',
|
|
ignoredNfts: 'baz',
|
|
extra: 'extra',
|
|
},
|
|
PreferencesController: {
|
|
extra: 'extra',
|
|
useNftDetection: 'foobar',
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it('should handle missing controller state', async () => {
|
|
const oldStorage = {
|
|
meta: {
|
|
version: 75,
|
|
},
|
|
data: {
|
|
CollectiblesController: {
|
|
extra: 'extra',
|
|
},
|
|
PreferencesController: {
|
|
extra: 'extra',
|
|
},
|
|
},
|
|
};
|
|
|
|
const newStorage = await migration76.migrate(oldStorage);
|
|
expect(newStorage).toStrictEqual({
|
|
meta: {
|
|
version: 76,
|
|
},
|
|
data: {
|
|
NftController: {
|
|
extra: 'extra',
|
|
},
|
|
PreferencesController: {
|
|
extra: 'extra',
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it('should handle missing CollectiblesController and PreferencesController', async () => {
|
|
const oldStorage = {
|
|
meta: {
|
|
version: 75,
|
|
},
|
|
data: {
|
|
FooController: { a: 'b' },
|
|
},
|
|
};
|
|
|
|
const newStorage = await migration76.migrate(oldStorage);
|
|
expect(newStorage).toStrictEqual({
|
|
meta: {
|
|
version: 76,
|
|
},
|
|
data: {
|
|
FooController: { a: 'b' },
|
|
},
|
|
});
|
|
});
|
|
});
|