summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-27 19:26:30 -0400
committerGitHub <noreply@github.com>2020-10-27 19:26:30 -0400
commitdfdefc15d31b401092760926756150a839f52487 (patch)
treec64c857814d7502676d93c88188d9397fff283ce /test
parent45627bd6e69324eb5b4ca86041ad44046d22f7f4 (diff)
Options fixes (#962)
* Fix default options not having the correct versions * Move schema validation * Remove legacy version number * Add tests for OptionsUtil.getDefault() * Remove unused getValidValueOrDefault
Diffstat (limited to 'test')
-rw-r--r--test/test-options-util.js30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/test-options-util.js b/test/test-options-util.js
index a7dc41d1..00786dd6 100644
--- a/test/test-options-util.js
+++ b/test/test-options-util.js
@@ -63,6 +63,7 @@ function clone(value) {
function createProfileOptionsTestData1() {
return {
+ version: 14,
general: {
enable: true,
enableClipboardPopups: false,
@@ -495,7 +496,7 @@ function createOptionsUpdatedTestData1() {
}
],
profileCurrent: 0,
- version: 4,
+ version: 5,
global: {
database: {
prefixWildcardsSupported: false
@@ -517,6 +518,32 @@ async function testUpdate(extDir) {
assert.deepStrictEqual(optionsUpdated, optionsExpected);
}
+async function testDefault(extDir) {
+ const data = [
+ (options) => options,
+ (options) => {
+ delete options.profiles[0].options.audio.autoPlay;
+ },
+ (options) => {
+ options.profiles[0].options.audio.autoPlay = void 0;
+ }
+ ];
+
+ const vm = createVM(extDir);
+ const [OptionsUtil] = vm.get(['OptionsUtil']);
+ const optionsUtil = new OptionsUtil();
+ await optionsUtil.prepare();
+
+ for (const modify of data) {
+ const options = optionsUtil.getDefault();
+
+ const optionsModified = clone(options);
+ modify(optionsModified);
+
+ const optionsUpdated = await optionsUtil.update(clone(optionsModified));
+ assert.deepStrictEqual(clone(optionsUpdated), clone(options));
+ }
+}
async function testFieldTemplatesUpdate(extDir) {
const vm = createVM(extDir);
@@ -590,6 +617,7 @@ ${update4}
async function main() {
const extDir = path.join(__dirname, '..', 'ext');
await testUpdate(extDir);
+ await testDefault(extDir);
await testFieldTemplatesUpdate(extDir);
}