OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 module("Preferences", | 3 module("Preferences", |
4 { | 4 { |
5 setup: function() | 5 setup: function() |
6 { | 6 { |
7 preparePrefs.call(this); | 7 preparePrefs.call(this); |
8 }, | 8 }, |
9 | 9 |
10 teardown: function() | 10 teardown: function() |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 equal(Prefs.enabled, true, "Prefs object returns the correct value after set
ting pref to default value"); | 74 equal(Prefs.enabled, true, "Prefs object returns the correct value after set
ting pref to default value"); |
75 equal(prefExists("enabled"), false, "User-defined pref has been removed"); | 75 equal(prefExists("enabled"), false, "User-defined pref has been removed"); |
76 Prefs.enabled = false; | 76 Prefs.enabled = false; |
77 equal(Prefs.enabled, false, "Prefs object returns the correct value after se
tting pref to non-default value"); | 77 equal(Prefs.enabled, false, "Prefs object returns the correct value after se
tting pref to non-default value"); |
78 equal(prefExists("enabled"), true, "User-defined pref has been created"); | 78 equal(prefExists("enabled"), true, "User-defined pref has been created"); |
79 checkPref("enabled", false, "Value has been written"); | 79 checkPref("enabled", false, "Value has been written"); |
80 }); | 80 }); |
81 | 81 |
82 test("String pref", function() | 82 test("String pref", function() |
83 { | 83 { |
84 Prefs.data_directory = "adblockplus"; | 84 Prefs.notificationurl = "https://notification.adblockplus.org/notification.j
son"; |
85 equal(Prefs.data_directory, "adblockplus", "Prefs object returns the correct
value after setting pref to default value"); | 85 equal(Prefs.notificationurl, "https://notification.adblockplus.org/notificat
ion.json", "Prefs object returns the correct value after setting pref to default
value"); |
86 equal(prefExists("data_directory"), false, "User-defined pref has been remov
ed"); | 86 equal(prefExists("notificationurl"), false, "User-defined pref has been remo
ved"); |
87 | 87 |
88 let newValue = "foo\u1234bar"; | 88 let newValue = "https://notification.adblockplus.org/foo\u1234bar.json"; |
89 Prefs.data_directory = newValue; | 89 Prefs.notificationurl = newValue; |
90 equal(Prefs.data_directory, newValue, "Prefs object returns the correct valu
e after setting pref to non-default value"); | 90 equal(Prefs.notificationurl, newValue, "Prefs object returns the correct val
ue after setting pref to non-default value"); |
91 equal(prefExists("data_directory"), true, "User-defined pref has been create
d"); | 91 equal(prefExists("notificationurl"), true, "User-defined pref has been creat
ed"); |
92 checkPref("data_directory", newValue, "Value has been written"); | 92 checkPref("notificationurl", newValue, "Value has been written"); |
93 }); | 93 }); |
94 | 94 |
95 test("Object pref (complete replacement)", function() | 95 test("Object pref (complete replacement)", function() |
96 { | 96 { |
97 Prefs.notificationdata = {}; | 97 Prefs.notificationdata = {}; |
98 deepEqual(Prefs.notificationdata, {}, "Prefs object returns the correct valu
e after setting pref to default value"); | 98 deepEqual(Prefs.notificationdata, {}, "Prefs object returns the correct valu
e after setting pref to default value"); |
99 equal(prefExists("notificationdata"), false, "User-defined pref has been rem
oved"); | 99 equal(prefExists("notificationdata"), false, "User-defined pref has been rem
oved"); |
100 | 100 |
101 let newValue = {foo:1, bar: "adsf\u1234"}; | 101 let newValue = {foo:1, bar: "adsf\u1234"}; |
102 Prefs.notificationdata = newValue; | 102 Prefs.notificationdata = newValue; |
(...skipping 13 matching lines...) Expand all Loading... |
116 equal(prefExists("notificationdata"), true, "User-defined pref has been crea
ted"); | 116 equal(prefExists("notificationdata"), true, "User-defined pref has been crea
ted"); |
117 checkPref("notificationdata", {foo:1, bar: 2}, "Value has been written"); | 117 checkPref("notificationdata", {foo:1, bar: 2}, "Value has been written"); |
118 | 118 |
119 delete Prefs.notificationdata.foo; | 119 delete Prefs.notificationdata.foo; |
120 delete Prefs.notificationdata.bar; | 120 delete Prefs.notificationdata.bar; |
121 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); | 121 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); |
122 deepEqual(Prefs.notificationdata, {}, "Prefs object returns the correct valu
e after setting pref to default value"); | 122 deepEqual(Prefs.notificationdata, {}, "Prefs object returns the correct valu
e after setting pref to default value"); |
123 equal(prefExists("notificationdata"), false, "User-defined pref has been rem
oved"); | 123 equal(prefExists("notificationdata"), false, "User-defined pref has been rem
oved"); |
124 }); | 124 }); |
125 })(); | 125 })(); |
OLD | NEW |