OLD | NEW |
(Empty) | |
| 1 "use strict"; |
| 2 |
| 3 let filterClasses = require("../lib/filterClassesNew"); |
| 4 let Filter = filterClasses.Filter; |
| 5 let InvalidFilter = filterClasses.InvalidFilter; |
| 6 let CommentFilter = filterClasses.CommentFilter; |
| 7 let RegExpFilter = filterClasses.RegExpFilter; |
| 8 let ElemHideFilter = filterClasses.ElemHideFilter; |
| 9 let ElemHideException = filterClasses.ElemHideException; |
| 10 |
| 11 exports.testFromText = function(test) |
| 12 { |
| 13 let tests = [ |
| 14 ["!asdf", CommentFilter, "comment"], |
| 15 ["asdf", RegExpFilter, "blocking"], |
| 16 ["##asdf", ElemHideFilter, "elemhide"], |
| 17 ["#@#asdf", ElemHideException, "elemhideexception"], |
| 18 ["foobar##asdf", ElemHideFilter, "elemhide"], |
| 19 ["foobar#@#asdf", ElemHideException, "elemhideexception"], |
| 20 ["foobar##a", ElemHideFilter, "elemhide"], |
| 21 ["foobar#@#a", ElemHideException, "elemhideexception"], |
| 22 |
| 23 ["foobar#asdf", RegExpFilter, "blocking"], |
| 24 ["foobar|foobas##asdf", RegExpFilter, "blocking"], |
| 25 ["foobar##asdf{asdf}", RegExpFilter, "blocking"], |
| 26 ["foobar##", RegExpFilter, "blocking"], |
| 27 ["foobar#@#", RegExpFilter, "blocking"], |
| 28 ]; |
| 29 for (let [text, type, typeName] of tests) |
| 30 { |
| 31 let filter = Filter.fromText(text); |
| 32 test.ok(filter, "Got filter for " + text); |
| 33 test.ok(filter instanceof type, "Correct filter type for " + text); |
| 34 test.equal(filter.type, typeName, "Type name for " + text + " is " + typeNam
e); |
| 35 } |
| 36 test.done(); |
| 37 } |
| 38 |
| 39 exports.testNormalize = function(test) |
| 40 { |
| 41 let tests = [ |
| 42 [" foo bar ", "foobar"], |
| 43 ["foobar", "foobar"], |
| 44 [" ! comment something ", "! comment something"], |
| 45 [" ! \n comment something ", "! comment something"], |
| 46 [" foo , bar ## foo > bar ", "foo,bar##foo > bar"], |
| 47 [" foo , bar #@# foo > bar ", "foo,bar#@#foo > bar"], |
| 48 ]; |
| 49 for (let [text, expected] of tests) |
| 50 test.equal(Filter.normalize(text), expected); |
| 51 test.done(); |
| 52 } |
OLD | NEW |