2020-01-09 04:34:58 +01:00
|
|
|
import assert from 'assert'
|
|
|
|
import migration34 from '../../../app/scripts/migrations/034'
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('migration #34', function () {
|
|
|
|
it('should update the version metadata', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {
|
|
|
|
version: 33,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
data: {},
|
2019-08-01 18:33:20 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.meta, {
|
2020-11-03 00:41:28 +01:00
|
|
|
version: 34,
|
2019-08-01 18:33:20 +02:00
|
|
|
})
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
.catch(done)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should set migratedPrivacyMode & privacyMode if featureFlags.privacyMode was false', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: false,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data.PreferencesController, {
|
2020-11-03 00:41:28 +01:00
|
|
|
migratedPrivacyMode: true,
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
.catch(done)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if migratedPrivacyMode is already set to true', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
migratedPrivacyMode: true,
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
.catch(done)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if migratedPrivacyMode is already set to false', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
migratedPrivacyMode: false,
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
.catch(done)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if PreferencesController is missing', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {},
|
2019-08-01 18:33:20 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
.catch(done)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if featureFlags.privacyMode is already true', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
.catch(done)
|
|
|
|
})
|
|
|
|
})
|