mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
d1cea85f33
* Rename `provider` to `providerConfig` The network controller `provider` state has been renamed to `providerConfig`. This better reflects what this state is, and makes this controller more closely aligned with the core network controller. All references to the provider configuration have been updated to prefer `providerConfig` over `provider`, to make the distinction clear between a provider and provider config. Closes #18902 * Add migration
89 lines
1.8 KiB
JavaScript
89 lines
1.8 KiB
JavaScript
import { migrate, version } from './086';
|
|
|
|
jest.mock('uuid', () => {
|
|
const actual = jest.requireActual('uuid');
|
|
|
|
return {
|
|
...actual,
|
|
v4: jest.fn(),
|
|
};
|
|
});
|
|
|
|
describe('migration #86', () => {
|
|
it('should update the version metadata', async () => {
|
|
const oldStorage = {
|
|
meta: {
|
|
version: 85,
|
|
},
|
|
data: {},
|
|
};
|
|
|
|
const newStorage = await migrate(oldStorage);
|
|
expect(newStorage.meta).toStrictEqual({
|
|
version,
|
|
});
|
|
});
|
|
|
|
it('should return state unaltered if there is no network controller state', async () => {
|
|
const oldData = {
|
|
other: 'data',
|
|
};
|
|
const oldStorage = {
|
|
meta: {
|
|
version: 85,
|
|
},
|
|
data: oldData,
|
|
};
|
|
|
|
const newStorage = await migrate(oldStorage);
|
|
expect(newStorage.data).toStrictEqual(oldData);
|
|
});
|
|
|
|
it('should return state unaltered if there is no network controller provider state', async () => {
|
|
const oldData = {
|
|
other: 'data',
|
|
NetworkController: {
|
|
networkConfigurations: {
|
|
foo: 'bar',
|
|
},
|
|
},
|
|
};
|
|
const oldStorage = {
|
|
meta: {
|
|
version: 85,
|
|
},
|
|
data: oldData,
|
|
};
|
|
|
|
const newStorage = await migrate(oldStorage);
|
|
expect(newStorage.data).toStrictEqual(oldData);
|
|
});
|
|
|
|
it('should rename the provider config state', async () => {
|
|
const oldData = {
|
|
other: 'data',
|
|
NetworkController: {
|
|
provider: {
|
|
some: 'provider',
|
|
},
|
|
},
|
|
};
|
|
const oldStorage = {
|
|
meta: {
|
|
version: 85,
|
|
},
|
|
data: oldData,
|
|
};
|
|
|
|
const newStorage = await migrate(oldStorage);
|
|
expect(newStorage.data).toStrictEqual({
|
|
other: 'data',
|
|
NetworkController: {
|
|
providerConfig: {
|
|
some: 'provider',
|
|
},
|
|
},
|
|
});
|
|
});
|
|
});
|