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

Unified Diff: qunit/tests/filterValidation.js

Issue 29452181: Noissue - Merge current tip to Edge bookmark (Closed)
Patch Set: Created May 30, 2017, 3:49 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
===================================================================
--- 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