Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: qunit/tests/filterValidation.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Rebased Created March 17, 2017, 12:41 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « qunit/tests/cssEscaping.js ('k') | qunit/tests/prefs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
});
-}
+}());
« no previous file with comments | « qunit/tests/cssEscaping.js ('k') | qunit/tests/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld