2021-05-07 21:38:24 +02:00
|
|
|
import { strict as assert } from 'assert';
|
2021-03-16 22:00:08 +01:00
|
|
|
import migration36 from './036';
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('migration #36', function () {
|
|
|
|
it('should update the version metadata', function (done) {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {
|
|
|
|
version: 35,
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration36
|
|
|
|
.migrate(oldStorage)
|
2019-08-15 23:07:18 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.meta, {
|
2020-11-03 00:41:28 +01:00
|
|
|
version: 36,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2019-08-15 23:07:18 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should remove privacyMode if featureFlags.privacyMode was false', function (done) {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: false,
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration36
|
|
|
|
.migrate(oldStorage)
|
2019-08-15 23:07:18 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data.PreferencesController, {
|
2020-11-03 00:41:28 +01:00
|
|
|
featureFlags: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2019-08-15 23:07:18 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should remove privacyMode if featureFlags.privacyMode was true', function (done) {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration36
|
|
|
|
.migrate(oldStorage)
|
2019-08-15 23:07:18 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data.PreferencesController, {
|
2020-11-03 00:41:28 +01:00
|
|
|
featureFlags: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2019-08-15 23:07:18 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if privacyMode does not exist', function (done) {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
migratedPrivacyMode: true,
|
|
|
|
featureFlags: {},
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration36
|
|
|
|
.migrate(oldStorage)
|
2019-08-15 23:07:18 +02:00
|
|
|
.then((newStorage) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
|
|
|
done();
|
2019-08-15 23:07:18 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if PreferencesController is missing', function (done) {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration36
|
|
|
|
.migrate(oldStorage)
|
2019-08-15 23:07:18 +02:00
|
|
|
.then((newStorage) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
|
|
|
done();
|
2019-08-15 23:07:18 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if featureFlags is missing', function (done) {
|
2019-08-15 23:07:18 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {},
|
2019-08-15 23:07:18 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-15 23:07:18 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration36
|
|
|
|
.migrate(oldStorage)
|
2019-08-15 23:07:18 +02:00
|
|
|
.then((newStorage) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
|
|
|
done();
|
2019-08-15 23:07:18 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|