LEFT | RIGHT |
1 "use strict"; | 1 "use strict"; |
2 | 2 |
3 { | 3 { |
4 let filterValidation = require("filterValidation"); | 4 const {parseFilter, parseFilters} = require("filterValidation"); |
5 let parseFilter = filterValidation.parseFilter; | 5 const {BlockingFilter, |
6 let parseFilters = filterValidation.parseFilters; | 6 ElemHideFilter, |
7 | 7 CommentFilter} = require("filterClasses"); |
8 let filterClasses = require("filterClasses"); | |
9 let BlockingFilter = filterClasses.BlockingFilter; | |
10 let ElemHideFilter = filterClasses.ElemHideFilter; | |
11 let CommentFilter = filterClasses.CommentFilter; | |
12 | 8 |
13 module("Filter validation"); | 9 module("Filter validation"); |
14 | 10 |
15 test("Detecting invalid filters", () => | 11 test("Detecting invalid filters", () => |
16 { | 12 { |
17 equal(parseFilter("||example.com^$unknown").error.type, "invalid-filter", "u
nknown option"); | 13 equal(parseFilter("||example.com^$unknown").error.type, "invalid-filter", "u
nknown option"); |
18 equal(parseFilter("[foobar]").error.type, "unexpected-filter-list-header", "
filter list header"); | 14 equal(parseFilter("[foobar]").error.type, "unexpected-filter-list-header", "
filter list header"); |
19 equal(parseFilter("##[foo").error.type, "invalid-css-selector", "invalid sel
ector"); | 15 equal(parseFilter("##[foo").error.type, "invalid-css-selector", "invalid sel
ector"); |
20 ok(/\b4\b/.test(parseFilters("!comment\r\n||example.com^\n\n##/").errors[0])
, "error contains corresponding line number"); | 16 ok(/\b4\b/.test(parseFilters("!comment\r\n||example.com^\n\n##/").errors[0])
, "error contains corresponding line number"); |
21 }); | 17 }); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 ok(result.filters[0] instanceof BlockingFilter, "1st filter is blocking"); | 56 ok(result.filters[0] instanceof BlockingFilter, "1st filter is blocking"); |
61 equal(result.filters[0].text, "||example.com^", "1st filter text matches"); | 57 equal(result.filters[0].text, "||example.com^", "1st filter text matches"); |
62 | 58 |
63 ok(result.filters[1] instanceof ElemHideFilter, "2nd filter is elemhide"); | 59 ok(result.filters[1] instanceof ElemHideFilter, "2nd filter is elemhide"); |
64 equal(result.filters[1].text, "###foobar", "2nd filter text matches"); | 60 equal(result.filters[1].text, "###foobar", "2nd filter text matches"); |
65 | 61 |
66 ok(result.filters[2] instanceof CommentFilter, "3rd filter is comment"); | 62 ok(result.filters[2] instanceof CommentFilter, "3rd filter is comment"); |
67 equal(result.filters[2].text, "! foo bar", "3rd filter text matches"); | 63 equal(result.filters[2].text, "! foo bar", "3rd filter text matches"); |
68 }); | 64 }); |
69 } | 65 } |
LEFT | RIGHT |