2021-02-04 19:15:23 +01:00
|
|
|
import { strict as assert } from 'assert';
|
2021-03-16 22:00:08 +01:00
|
|
|
import migration46 from './046';
|
2020-05-19 17:57:06 +02:00
|
|
|
|
|
|
|
describe('migration #46', function () {
|
|
|
|
it('should update the version metadata', async function () {
|
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {
|
|
|
|
version: 45,
|
2020-05-19 17:57:06 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-05-19 17:57:06 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration46.migrate(oldStorage);
|
2020-05-19 17:57:06 +02:00
|
|
|
assert.deepEqual(newStorage.meta, {
|
2020-11-03 00:41:28 +01:00
|
|
|
version: 46,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-05-19 17:57:06 +02:00
|
|
|
|
|
|
|
it('should delete ABTestController state', async function () {
|
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
ABTestController: {
|
|
|
|
abTests: {
|
|
|
|
fullScreenVsPopup: 'control',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-05-19 17:57:06 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration46.migrate(oldStorage);
|
2020-05-19 17:57:06 +02:00
|
|
|
assert.deepEqual(newStorage.data, {
|
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-05-19 17:57:06 +02:00
|
|
|
|
|
|
|
it('should do nothing if ABTestController state does not exist', async function () {
|
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
AppStateController: {
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-05-19 17:57:06 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const newStorage = await migration46.migrate(oldStorage);
|
|
|
|
assert.deepEqual(oldStorage.data, newStorage.data);
|
|
|
|
});
|
|
|
|
});
|