2021-02-04 19:15:23 +01:00
|
|
|
import assert from 'assert';
|
2021-03-16 22:00:08 +01:00
|
|
|
import migration45 from './045';
|
2020-05-14 12:26:27 +02:00
|
|
|
|
|
|
|
describe('migration #45', function () {
|
|
|
|
it('should update the version metadata', function (done) {
|
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {
|
|
|
|
version: 44,
|
2020-05-14 12:26:27 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-05-14 12:26:27 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration45
|
|
|
|
.migrate(oldStorage)
|
2020-05-14 12:26:27 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.meta, {
|
2020-11-03 00:41:28 +01:00
|
|
|
version: 45,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2020-05-14 12:26:27 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2020-05-14 12:26:27 +02:00
|
|
|
|
|
|
|
it('should update ipfsGateway value if outdated', function (done) {
|
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
ipfsGateway: 'ipfs.dweb.link',
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-05-14 12:26:27 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration45
|
|
|
|
.migrate(oldStorage)
|
2020-05-14 12:26:27 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data, {
|
|
|
|
PreferencesController: {
|
|
|
|
ipfsGateway: 'dweb.link',
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2020-05-14 12:26:27 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2020-05-14 12:26:27 +02:00
|
|
|
|
|
|
|
it('should not update ipfsGateway value if custom set', function (done) {
|
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
ipfsGateway: 'blah',
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-05-14 12:26:27 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration45
|
|
|
|
.migrate(oldStorage)
|
2020-05-14 12:26:27 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data, {
|
|
|
|
PreferencesController: {
|
|
|
|
ipfsGateway: 'blah',
|
|
|
|
bar: 'baz',
|
|
|
|
},
|
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2020-05-14 12:26:27 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2020-05-14 12:26:27 +02:00
|
|
|
|
|
|
|
it('should do nothing if no PreferencesController key', function (done) {
|
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
foo: 'bar',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-05-14 12:26:27 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration45
|
|
|
|
.migrate(oldStorage)
|
2020-05-14 12:26:27 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data, {
|
|
|
|
foo: 'bar',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2020-05-14 12:26:27 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|