OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 module("Filter matcher", {setup: prepareFilterComponents, teardown: restoreFil
terComponents}); | 3 module("Filter matcher", {setup: prepareFilterComponents, teardown: restoreFil
terComponents}); |
4 | 4 |
5 function compareKeywords(text, expected) | 5 function compareKeywords(text, expected) |
6 { | 6 { |
7 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)]) | 7 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)]) |
8 { | 8 { |
9 let matcher = new Matcher(); | 9 let matcher = new Matcher(); |
10 let result = []; | 10 let result = []; |
11 for (let dummy of expected) | 11 for (let dummy of expected) |
12 { | 12 { |
13 keyword = matcher.findKeyword(filter); | 13 let keyword = matcher.findKeyword(filter); |
14 result.push(keyword); | 14 result.push(keyword); |
15 if (keyword) | 15 if (keyword) |
16 { | 16 { |
17 let dummyFilter = Filter.fromText('^' + keyword + '^'); | 17 let dummyFilter = Filter.fromText('^' + keyword + '^'); |
18 dummyFilter.filterCount = Infinity; | 18 dummyFilter.filterCount = Infinity; |
19 matcher.add(dummyFilter); | 19 matcher.add(dummyFilter); |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 equal(result.join(", "), expected.join(", "), "Keyword candidates for " +
filter.text); | 23 equal(result.join(", "), expected.join(", "), "Keyword candidates for " +
filter.text); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p
arty,~script"); | 179 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p
arty,~script"); |
180 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par
ty"); | 180 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par
ty"); |
181 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, false, "cba$~third-p
arty,~script"); | 181 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, false, "cba$~third-p
arty,~script"); |
182 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, true, "cba$third-par
ty"); | 182 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, true, "cba$third-par
ty"); |
183 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); | 183 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); |
184 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, false, "http:
//fed$~third-party,~script"); | 184 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, false, "http:
//fed$~third-party,~script"); |
185 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, true, "http:/
/fed$third-party"); | 185 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, true, "http:/
/fed$third-party"); |
186 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http://
def$script"); | 186 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http://
def$script"); |
187 }); | 187 }); |
188 })(); | 188 })(); |
OLD | NEW |