You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
2.6 KiB
122 lines
2.6 KiB
4 years ago
|
import assert from 'assert';
|
||
4 years ago
|
import migration36 from './036';
|
||
5 years ago
|
|
||
5 years ago
|
describe('migration #36', function () {
|
||
|
it('should update the version metadata', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {
|
||
|
version: 35,
|
||
5 years ago
|
},
|
||
4 years ago
|
data: {},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration36
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
|
assert.deepEqual(newStorage.meta, {
|
||
4 years ago
|
version: 36,
|
||
4 years ago
|
});
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should remove privacyMode if featureFlags.privacyMode was false', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
featureFlags: {
|
||
|
privacyMode: false,
|
||
5 years ago
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration36
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
|
assert.deepEqual(newStorage.data.PreferencesController, {
|
||
4 years ago
|
featureFlags: {},
|
||
4 years ago
|
});
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should remove privacyMode if featureFlags.privacyMode was true', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
featureFlags: {
|
||
|
privacyMode: true,
|
||
5 years ago
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration36
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
|
assert.deepEqual(newStorage.data.PreferencesController, {
|
||
4 years ago
|
featureFlags: {},
|
||
4 years ago
|
});
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if privacyMode does not exist', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {
|
||
|
migratedPrivacyMode: true,
|
||
|
featureFlags: {},
|
||
5 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration36
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if PreferencesController is missing', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration36
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('should NOT change any state if featureFlags is missing', function (done) {
|
||
5 years ago
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
PreferencesController: {},
|
||
5 years ago
|
},
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
migration36
|
||
|
.migrate(oldStorage)
|
||
5 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
|
});
|