LEFT | RIGHT |
| 1 "use strict"; |
| 2 |
1 { | 3 { |
2 let filterValidation = require("filterValidation"); | 4 const {parseFilter, parseFilters} = require("filterValidation"); |
3 let parseFilter = filterValidation.parseFilter; | 5 const {BlockingFilter, |
4 let parseFilters = filterValidation.parseFilters; | 6 ElemHideFilter, |
5 | 7 CommentFilter} = require("filterClasses"); |
6 let filterClasses = require("filterClasses"); | |
7 let BlockingFilter = filterClasses.BlockingFilter; | |
8 let ElemHideFilter = filterClasses.ElemHideFilter; | |
9 let CommentFilter = filterClasses.CommentFilter; | |
10 | 8 |
11 module("Filter validation"); | 9 module("Filter validation"); |
12 | 10 |
13 test("Detecting invalid filters", () => | 11 test("Detecting invalid filters", () => |
14 { | 12 { |
15 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"); |
16 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"); |
17 equal(parseFilter("##[foo").error.type, "invalid-css-selector", "invalid sel
ector"); | 15 equal(parseFilter("##[foo").error.type, "invalid-css-selector", "invalid sel
ector"); |
18 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"); |
19 }); | 17 }); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 ok(result.filters[0] instanceof BlockingFilter, "1st filter is blocking"); | 56 ok(result.filters[0] instanceof BlockingFilter, "1st filter is blocking"); |
59 equal(result.filters[0].text, "||example.com^", "1st filter text matches"); | 57 equal(result.filters[0].text, "||example.com^", "1st filter text matches"); |
60 | 58 |
61 ok(result.filters[1] instanceof ElemHideFilter, "2nd filter is elemhide"); | 59 ok(result.filters[1] instanceof ElemHideFilter, "2nd filter is elemhide"); |
62 equal(result.filters[1].text, "###foobar", "2nd filter text matches"); | 60 equal(result.filters[1].text, "###foobar", "2nd filter text matches"); |
63 | 61 |
64 ok(result.filters[2] instanceof CommentFilter, "3rd filter is comment"); | 62 ok(result.filters[2] instanceof CommentFilter, "3rd filter is comment"); |
65 equal(result.filters[2].text, "! foo bar", "3rd filter text matches"); | 63 equal(result.filters[2].text, "! foo bar", "3rd filter text matches"); |
66 }); | 64 }); |
67 } | 65 } |
LEFT | RIGHT |