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

Delta Between Two Patch Sets: test/subscriptionClasses.js

Issue 30025555: Issue 6820 - Move tests to mocha (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Rebased. Created April 5, 2019, 4:16 p.m.
Right Patch Set: Rebased Created April 10, 2019, 6:33 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/snippets.js ('k') | test/synchronizer.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 }); 131 });
132 132
133 it("Filter Management", () => 133 it("Filter Management", () =>
134 { 134 {
135 let subscription = Subscription.fromURL("https://example.com/"); 135 let subscription = Subscription.fromURL("https://example.com/");
136 136
137 compareSubscriptionFilters(subscription, []); 137 compareSubscriptionFilters(subscription, []);
138 138
139 subscription.addFilter(f$("##.foo")); 139 subscription.addFilter(f$("##.foo"));
140 compareSubscriptionFilters(subscription, ["##.foo"]); 140 compareSubscriptionFilters(subscription, ["##.foo"]);
141 assert.equal(subscription.searchFilter(f$("##.foo")), 0); 141 assert.equal(subscription.findFilterIndex(f$("##.foo")), 0);
142 142
143 subscription.addFilter(f$("##.bar")); 143 subscription.addFilter(f$("##.bar"));
144 compareSubscriptionFilters(subscription, ["##.foo", "##.bar"]); 144 compareSubscriptionFilters(subscription, ["##.foo", "##.bar"]);
145 assert.equal(subscription.searchFilter(f$("##.bar")), 1); 145 assert.equal(subscription.findFilterIndex(f$("##.bar")), 1);
146 146
147 // Repeat filter. 147 // Repeat filter.
148 subscription.addFilter(f$("##.bar")); 148 subscription.addFilter(f$("##.bar"));
149 compareSubscriptionFilters(subscription, ["##.foo", "##.bar", 149 compareSubscriptionFilters(subscription, ["##.foo", "##.bar",
150 "##.bar"]); 150 "##.bar"]);
151 151
152 // The first occurrence is found. 152 // The first occurrence is found.
153 assert.equal(subscription.searchFilter(f$("##.bar")), 1); 153 assert.equal(subscription.findFilterIndex(f$("##.bar")), 1);
154 154
155 subscription.deleteFilterAt(0); 155 subscription.deleteFilterAt(0);
156 compareSubscriptionFilters(subscription, ["##.bar", "##.bar"]); 156 compareSubscriptionFilters(subscription, ["##.bar", "##.bar"]);
157 assert.equal(subscription.searchFilter(f$("##.bar")), 0); 157 assert.equal(subscription.findFilterIndex(f$("##.bar")), 0);
158 158
159 subscription.insertFilterAt(f$("##.foo"), 0); 159 subscription.insertFilterAt(f$("##.foo"), 0);
160 compareSubscriptionFilters(subscription, ["##.foo", "##.bar", 160 compareSubscriptionFilters(subscription, ["##.foo", "##.bar",
161 "##.bar"]); 161 "##.bar"]);
162 assert.equal(subscription.searchFilter(f$("##.bar")), 1); 162 assert.equal(subscription.findFilterIndex(f$("##.bar")), 1);
163 163
164 subscription.deleteFilterAt(1); 164 subscription.deleteFilterAt(1);
165 compareSubscriptionFilters(subscription, ["##.foo", "##.bar"]); 165 compareSubscriptionFilters(subscription, ["##.foo", "##.bar"]);
166 assert.equal(subscription.searchFilter(f$("##.bar")), 1); 166 assert.equal(subscription.findFilterIndex(f$("##.bar")), 1);
167 167
168 subscription.deleteFilterAt(1); 168 subscription.deleteFilterAt(1);
169 compareSubscriptionFilters(subscription, ["##.foo"]); 169 compareSubscriptionFilters(subscription, ["##.foo"]);
170 assert.equal(subscription.searchFilter(f$("##.bar")), -1); 170 assert.equal(subscription.findFilterIndex(f$("##.bar")), -1);
171 171
172 subscription.addFilter(f$("##.bar")); 172 subscription.addFilter(f$("##.bar"));
173 compareSubscriptionFilters(subscription, ["##.foo", "##.bar"]); 173 compareSubscriptionFilters(subscription, ["##.foo", "##.bar"]);
174 assert.equal(subscription.searchFilter(f$("##.bar")), 1); 174 assert.equal(subscription.findFilterIndex(f$("##.bar")), 1);
175 175
176 subscription.clearFilters(); 176 subscription.clearFilters();
177 compareSubscriptionFilters(subscription, []); 177 compareSubscriptionFilters(subscription, []);
178 assert.equal(subscription.searchFilter(f$("##.foo")), -1); 178 assert.equal(subscription.findFilterIndex(f$("##.foo")), -1);
179 assert.equal(subscription.searchFilter(f$("##.bar")), -1); 179 assert.equal(subscription.findFilterIndex(f$("##.bar")), -1);
180 180
181 subscription.addFilter(f$("##.bar")); 181 subscription.addFilter(f$("##.bar"));
182 compareSubscriptionFilters(subscription, ["##.bar"]); 182 compareSubscriptionFilters(subscription, ["##.bar"]);
183 183
184 subscription.addFilter(f$("##.foo")); 184 subscription.addFilter(f$("##.foo"));
185 compareSubscriptionFilters(subscription, ["##.bar", "##.foo"]); 185 compareSubscriptionFilters(subscription, ["##.bar", "##.foo"]);
186 assert.equal(subscription.searchFilter(f$("##.bar")), 0); 186 assert.equal(subscription.findFilterIndex(f$("##.bar")), 0);
187 assert.equal(subscription.searchFilter(f$("##.foo")), 1); 187 assert.equal(subscription.findFilterIndex(f$("##.foo")), 1);
188 188
189 // Insert outside of bounds. 189 // Insert outside of bounds.
190 subscription.insertFilterAt(f$("##.lambda"), 1000); 190 subscription.insertFilterAt(f$("##.lambda"), 1000);
191 compareSubscriptionFilters(subscription, ["##.bar", "##.foo", 191 compareSubscriptionFilters(subscription, ["##.bar", "##.foo",
192 "##.lambda"]); 192 "##.lambda"]);
193 assert.equal(subscription.searchFilter(f$("##.lambda")), 2); 193 assert.equal(subscription.findFilterIndex(f$("##.lambda")), 2);
194 194
195 // Delete outside of bounds. 195 // Delete outside of bounds.
196 subscription.deleteFilterAt(1000); 196 subscription.deleteFilterAt(1000);
197 compareSubscriptionFilters(subscription, ["##.bar", "##.foo", 197 compareSubscriptionFilters(subscription, ["##.bar", "##.foo",
198 "##.lambda"]); 198 "##.lambda"]);
199 assert.equal(subscription.searchFilter(f$("##.lambda")), 2); 199 assert.equal(subscription.findFilterIndex(f$("##.lambda")), 2);
200 200
201 // Insert outside of bounds (negative). 201 // Insert outside of bounds (negative).
202 subscription.insertFilterAt(f$("##.lambda"), -1000); 202 subscription.insertFilterAt(f$("##.lambda"), -1000);
203 compareSubscriptionFilters(subscription, ["##.lambda", "##.bar", 203 compareSubscriptionFilters(subscription, ["##.lambda", "##.bar",
204 "##.foo", "##.lambda"]); 204 "##.foo", "##.lambda"]);
205 assert.equal(subscription.searchFilter(f$("##.lambda")), 0); 205 assert.equal(subscription.findFilterIndex(f$("##.lambda")), 0);
206 206
207 // Delete outside of bounds (negative). 207 // Delete outside of bounds (negative).
208 subscription.deleteFilterAt(-1000); 208 subscription.deleteFilterAt(-1000);
209 compareSubscriptionFilters(subscription, ["##.lambda", "##.bar", 209 compareSubscriptionFilters(subscription, ["##.lambda", "##.bar",
210 "##.foo", "##.lambda"]); 210 "##.foo", "##.lambda"]);
211 assert.equal(subscription.searchFilter(f$("##.lambda")), 0); 211 assert.equal(subscription.findFilterIndex(f$("##.lambda")), 0);
212 }); 212 });
213 }); 213 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld