Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | "use strict"; |
michael@0 | 4 | |
michael@0 | 5 | function test() { |
michael@0 | 6 | let prefs = TiltUtils.Preferences; |
michael@0 | 7 | ok(prefs, "The TiltUtils.Preferences wasn't found."); |
michael@0 | 8 | |
michael@0 | 9 | prefs.create("test-pref-bool", "boolean", true); |
michael@0 | 10 | prefs.create("test-pref-int", "integer", 42); |
michael@0 | 11 | prefs.create("test-pref-string", "string", "hello world!"); |
michael@0 | 12 | |
michael@0 | 13 | is(prefs.get("test-pref-bool", "boolean"), true, |
michael@0 | 14 | "The boolean test preference wasn't initially set correctly."); |
michael@0 | 15 | is(prefs.get("test-pref-int", "integer"), 42, |
michael@0 | 16 | "The integer test preference wasn't initially set correctly."); |
michael@0 | 17 | is(prefs.get("test-pref-string", "string"), "hello world!", |
michael@0 | 18 | "The string test preference wasn't initially set correctly."); |
michael@0 | 19 | |
michael@0 | 20 | |
michael@0 | 21 | prefs.set("test-pref-bool", "boolean", false); |
michael@0 | 22 | prefs.set("test-pref-int", "integer", 24); |
michael@0 | 23 | prefs.set("test-pref-string", "string", "!dlrow olleh"); |
michael@0 | 24 | |
michael@0 | 25 | is(prefs.get("test-pref-bool", "boolean"), false, |
michael@0 | 26 | "The boolean test preference wasn't changed correctly."); |
michael@0 | 27 | is(prefs.get("test-pref-int", "integer"), 24, |
michael@0 | 28 | "The integer test preference wasn't changed correctly."); |
michael@0 | 29 | is(prefs.get("test-pref-string", "string"), "!dlrow olleh", |
michael@0 | 30 | "The string test preference wasn't changed correctly."); |
michael@0 | 31 | |
michael@0 | 32 | |
michael@0 | 33 | is(typeof prefs.get("unknown-pref", "boolean"), "undefined", |
michael@0 | 34 | "Inexisted boolean prefs should be handled as undefined."); |
michael@0 | 35 | is(typeof prefs.get("unknown-pref", "integer"), "undefined", |
michael@0 | 36 | "Inexisted integer prefs should be handled as undefined."); |
michael@0 | 37 | is(typeof prefs.get("unknown-pref", "string"), "undefined", |
michael@0 | 38 | "Inexisted string prefs should be handled as undefined."); |
michael@0 | 39 | |
michael@0 | 40 | |
michael@0 | 41 | is(prefs.get("test-pref-bool", "integer"), null, |
michael@0 | 42 | "The get() boolean function didn't handle incorrect types as it should."); |
michael@0 | 43 | is(prefs.get("test-pref-bool", "string"), null, |
michael@0 | 44 | "The get() boolean function didn't handle incorrect types as it should."); |
michael@0 | 45 | is(prefs.get("test-pref-int", "boolean"), null, |
michael@0 | 46 | "The get() integer function didn't handle incorrect types as it should."); |
michael@0 | 47 | is(prefs.get("test-pref-int", "string"), null, |
michael@0 | 48 | "The get() integer function didn't handle incorrect types as it should."); |
michael@0 | 49 | is(prefs.get("test-pref-string", "boolean"), null, |
michael@0 | 50 | "The get() string function didn't handle incorrect types as it should."); |
michael@0 | 51 | is(prefs.get("test-pref-string", "integer"), null, |
michael@0 | 52 | "The get() string function didn't handle incorrect types as it should."); |
michael@0 | 53 | |
michael@0 | 54 | |
michael@0 | 55 | is(typeof prefs.get(), "undefined", |
michael@0 | 56 | "The get() function should not work if not enough params are passed."); |
michael@0 | 57 | is(typeof prefs.set(), "undefined", |
michael@0 | 58 | "The set() function should not work if not enough params are passed."); |
michael@0 | 59 | is(typeof prefs.create(), "undefined", |
michael@0 | 60 | "The create() function should not work if not enough params are passed."); |
michael@0 | 61 | |
michael@0 | 62 | |
michael@0 | 63 | is(prefs.get("test-pref-wrong-type", "wrong-type", 1), null, |
michael@0 | 64 | "The get() function should expect only correct pref types."); |
michael@0 | 65 | is(prefs.set("test-pref-wrong-type", "wrong-type", 1), false, |
michael@0 | 66 | "The set() function should expect only correct pref types."); |
michael@0 | 67 | is(prefs.create("test-pref-wrong-type", "wrong-type", 1), false, |
michael@0 | 68 | "The create() function should expect only correct pref types."); |
michael@0 | 69 | } |