Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: qunit/tests/prefs.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Fixed typo with shadowRoot getter Created March 14, 2017, 10:28 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* globals preparePrefs, restorePrefs, Prefs */
2
1 "use strict"; 3 "use strict";
2 4
5 (function()
3 { 6 {
4 module("Preferences", 7 module("Preferences", {
5 {
6 setup() 8 setup()
7 { 9 {
8 preparePrefs.call(this); 10 preparePrefs.call(this);
9 }, 11 },
10 12
11 teardown() 13 teardown()
12 { 14 {
13 restorePrefs.call(this); 15 restorePrefs.call(this);
14 } 16 }
15 }); 17 });
(...skipping 16 matching lines...) Expand all
32 chrome.storage.local.get(key, items => 34 chrome.storage.local.get(key, items =>
33 { 35 {
34 deepEqual(items[key], expectedValue, description); 36 deepEqual(items[key], expectedValue, description);
35 done(); 37 done();
36 }); 38 });
37 } 39 }
38 40
39 test("Numerical pref", assert => 41 test("Numerical pref", assert =>
40 { 42 {
41 Prefs.patternsbackups = 5; 43 Prefs.patternsbackups = 5;
42 equal(Prefs.patternsbackups, 5, "Prefs object returns the correct value afte r setting pref to default value"); 44 equal(
43 checkPrefExists("patternsbackups", false, "User-defined pref has been remove d", assert); 45 Prefs.patternsbackups, 5,
46 "Prefs object returns the correct value after setting pref to " +
47 "default value"
48 );
49 checkPrefExists(
50 "patternsbackups", false, "User-defined pref has been removed", assert
51 );
44 Prefs.patternsbackups = 12; 52 Prefs.patternsbackups = 12;
45 equal(Prefs.patternsbackups, 12, "Prefs object returns the correct value aft er setting pref to non-default value"); 53 equal(
46 checkPrefExists("patternsbackups", true, "User-defined pref has been created ", assert); 54 Prefs.patternsbackups, 12,
55 "Prefs object returns the correct value after setting pref to " +
56 "non-default value"
57 );
58 checkPrefExists(
59 "patternsbackups", true, "User-defined pref has been created", assert
60 );
47 checkPref("patternsbackups", 12, "Value has been written", assert); 61 checkPref("patternsbackups", 12, "Value has been written", assert);
48 }); 62 });
49 63
50 test("Boolean pref", assert => 64 test("Boolean pref", assert =>
51 { 65 {
52 Prefs.enabled = true; 66 Prefs.enabled = true;
53 equal(Prefs.enabled, true, "Prefs object returns the correct value after set ting pref to default value"); 67 equal(
54 checkPrefExists("enabled", false, "User-defined pref has been removed", asse rt); 68 Prefs.enabled, true,
69 "Prefs object returns the correct value after setting pref to " +
70 "default value"
71 );
72 checkPrefExists("enabled", false, "User-defined pref has been removed",
73 assert);
55 Prefs.enabled = false; 74 Prefs.enabled = false;
56 equal(Prefs.enabled, false, "Prefs object returns the correct value after se tting pref to non-default value"); 75 equal(
57 checkPrefExists("enabled", true, "User-defined pref has been created", asser t); 76 Prefs.enabled, false,
77 "Prefs object returns the correct value after setting pref to " +
78 "non-default value"
79 );
80 checkPrefExists("enabled", true, "User-defined pref has been created",
81 assert);
58 checkPref("enabled", false, "Value has been written", assert); 82 checkPref("enabled", false, "Value has been written", assert);
59 }); 83 });
60 84
61 test("String pref", assert => 85 test("String pref", assert =>
62 { 86 {
63 let defaultValue = "https://notification.adblockplus.org/notification.json"; 87 let defaultValue = "https://notification.adblockplus.org/notification.json";
64 Prefs.notificationurl = defaultValue; 88 Prefs.notificationurl = defaultValue;
65 equal(Prefs.notificationurl, defaultValue, "Prefs object returns the correct value after setting pref to default value"); 89 equal(
66 checkPrefExists("notificationurl", false, "User-defined pref has been remove d", assert); 90 Prefs.notificationurl, defaultValue,
91 "Prefs object returns the correct value after setting pref to " +
92 "default value"
93 );
94 checkPrefExists("notificationurl", false,
95 "User-defined pref has been removed", assert);
67 96
68 let newValue = "https://notification.adblockplus.org/foo\u1234bar.json"; 97 let newValue = "https://notification.adblockplus.org/foo\u1234bar.json";
69 Prefs.notificationurl = newValue; 98 Prefs.notificationurl = newValue;
70 equal(Prefs.notificationurl, newValue, "Prefs object returns the correct val ue after setting pref to non-default value"); 99 equal(
71 checkPrefExists("notificationurl", true, "User-defined pref has been created ", assert); 100 Prefs.notificationurl, newValue,
101 "Prefs object returns the correct value after setting pref to " +
102 "non-default value"
103 );
104 checkPrefExists("notificationurl", true,
105 "User-defined pref has been created", assert);
72 checkPref("notificationurl", newValue, "Value has been written", assert); 106 checkPref("notificationurl", newValue, "Value has been written", assert);
73 }); 107 });
74 108
75 test("Object pref (complete replacement)", assert => 109 test("Object pref (complete replacement)", assert =>
76 { 110 {
77 Prefs.notificationdata = {}; 111 Prefs.notificationdata = {};
78 deepEqual(Prefs.notificationdata, {}, "Prefs object returns the correct valu e after setting pref to default value"); 112 deepEqual(
113 Prefs.notificationdata, {},
114 "Prefs object returns the correct value after setting pref to " +
115 "default value"
116 );
79 117
80 let newValue = {foo:1, bar: "adsf\u1234"}; 118 let newValue = {foo: 1, bar: "adsf\u1234"};
81 Prefs.notificationdata = newValue; 119 Prefs.notificationdata = newValue;
82 equal(Prefs.notificationdata, newValue, "Prefs object returns the correct va lue after setting pref to non-default value"); 120 equal(
83 checkPrefExists("notificationdata", true, "User-defined pref has been create d", assert); 121 Prefs.notificationdata, newValue,
122 "Prefs object returns the correct value after setting pref to " +
123 "non-default value"
124 );
125 checkPrefExists("notificationdata", true,
126 "User-defined pref has been created", assert);
84 checkPref("notificationdata", newValue, "Value has been written", assert); 127 checkPref("notificationdata", newValue, "Value has been written", assert);
85 }); 128 });
86 129
87 test("Property-wise modification", assert => 130 test("Property-wise modification", assert =>
88 { 131 {
89 Prefs.notificationdata = {}; 132 Prefs.notificationdata = {};
90 133
91 Prefs.notificationdata.foo = 1; 134 Prefs.notificationdata.foo = 1;
92 Prefs.notificationdata.bar = 2; 135 Prefs.notificationdata.bar = 2;
93 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); 136 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata));
94 deepEqual(Prefs.notificationdata, {foo:1, bar: 2}, "Prefs object returns the correct value after setting pref to non-default value"); 137 deepEqual(
95 checkPrefExists("notificationdata", true, "User-defined pref has been create d", assert); 138 Prefs.notificationdata, {foo: 1, bar: 2},
96 checkPref("notificationdata", {foo:1, bar: 2}, "Value has been written", ass ert); 139 "Prefs object returns the correct value after setting pref to " +
140 "non-default value"
141 );
142 checkPrefExists("notificationdata", true,
143 "User-defined pref has been created", assert);
144 checkPref("notificationdata", {foo: 1, bar: 2}, "Value has been written",
145 assert);
97 146
98 delete Prefs.notificationdata.foo; 147 delete Prefs.notificationdata.foo;
99 delete Prefs.notificationdata.bar; 148 delete Prefs.notificationdata.bar;
100 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); 149 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata));
101 deepEqual(Prefs.notificationdata, {}, "Prefs object returns the correct valu e after setting pref to default value"); 150 deepEqual(
151 Prefs.notificationdata, {},
152 "Prefs object returns the correct value after setting pref to " +
153 "default value"
154 );
102 }); 155 });
103 } 156 }());
OLDNEW
« qunit/common.js ('K') | « qunit/tests/filterValidation.js ('k') | qunit/tests/url.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld