Index: qunit/tests/filterValidation.js |
diff --git a/qunit/tests/filterValidation.js b/qunit/tests/filterValidation.js |
index 9f8cd721a15bdfd1827f31f3b2d15d7285b910b3..403c96bf85f162250234d3d2de994970a998dae1 100644 |
--- a/qunit/tests/filterValidation.js |
+++ b/qunit/tests/filterValidation.js |
@@ -10,28 +10,35 @@ |
test("Detecting invalid filters", () => |
{ |
- equal(parseFilter("||example.com^$unknown").error.type, "invalid-filter", "unknown option"); |
- equal(parseFilter("[foobar]").error.type, "unexpected-filter-list-header", "filter list header"); |
- equal(parseFilter("##[foo").error.type, "invalid-css-selector", "invalid selector"); |
- ok(/\b4\b/.test(parseFilters("!comment\r\n||example.com^\n\n##/").errors[0]), "error contains corresponding line number"); |
+ equal(parseFilter("||example.com^$unknown").error.type, "invalid-filter", |
+ "unknown option"); |
+ equal(parseFilter("[foobar]").error.type, "unexpected-filter-list-header", |
+ "filter list header"); |
+ equal(parseFilter("##[foo").error.type, "invalid-css-selector", |
+ "invalid selector"); |
+ ok( |
+ /\b4\b/.test(parseFilters("!comment\r\n||example.com^\n\n##/").errors[0]), |
+ "error contains corresponding line number" |
+ ); |
}); |
test("Allowing valid filters", () => |
{ |
- let text, filter; |
+ let text; |
+ let filter; |
text = "||example.com^"; |
- filter = parseFilter(text).filter; |
+ ({filter} = parseFilter(text)); |
ok(filter instanceof BlockingFilter, "blocking filter parsed"); |
equal(filter.text, text, "blocking filter text matches"); |
text = '##div:first-child a[src="http://example.com"] > .foo + #bar'; |
- filter = parseFilter(text).filter; |
+ ({filter} = parseFilter(text)); |
ok(filter instanceof ElemHideFilter, "elemhide filter parsed"); |
equal(filter.text, text, "elemhide filter text matches"); |
text = "! foo bar"; |
- filter = parseFilter(text).filter; |
+ ({filter} = parseFilter(text)); |
ok(filter instanceof CommentFilter, "comment filter parsed"); |
equal(filter.text, text, "comment filter text matches"); |
@@ -41,8 +48,9 @@ |
test("Normalizing filters", () => |
{ |
let ws = " \t\r\n"; |
- |
- equal(parseFilter(ws + "@@" + ws + "||" + ws + "example.com" + ws + "^" + ws).filter.text, "@@||example.com^", "unnecessary spaces"); |
+ let filterText = ws + "@@" + ws + "||" + ws + "example.com" + ws + "^" + ws; |
+ equal(parseFilter(filterText).filter.text, "@@||example.com^", |
+ "unnecessary spaces"); |
equal(parseFilter(ws).filter, null, "only spaces"); |
}); |
@@ -57,9 +65,9 @@ |
equal(result.filters[0].text, "||example.com^", "1st filter text matches"); |
ok(result.filters[1] instanceof ElemHideFilter, "2nd filter is elemhide"); |
- equal(result.filters[1].text, "###foobar", "2nd filter text matches"); |
+ equal(result.filters[1].text, "###foobar", "2nd filter text matches"); |
- ok(result.filters[2] instanceof CommentFilter, "3rd filter is comment"); |
- equal(result.filters[2].text, "! foo bar", "3rd filter text matches"); |
+ ok(result.filters[2] instanceof CommentFilter, "3rd filter is comment"); |
+ equal(result.filters[2].text, "! foo bar", "3rd filter text matches"); |
}); |
} |