Index: qunit/tests/filterValidation.js |
diff --git a/qunit/tests/filterValidation.js b/qunit/tests/filterValidation.js |
index 9f8cd721a15bdfd1827f31f3b2d15d7285b910b3..ad1e5c276bf40cb16a553b1fc32da0761873dcde 100644 |
--- a/qunit/tests/filterValidation.js |
+++ b/qunit/tests/filterValidation.js |
@@ -1,5 +1,6 @@ |
"use strict"; |
+(function() |
{ |
const {parseFilter, parseFilters} = require("filterValidation"); |
const {BlockingFilter, |
@@ -10,28 +11,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 +49,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 +66,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"); |
}); |
-} |
+}()); |