Index: test/snippets.js |
=================================================================== |
--- a/test/snippets.js |
+++ b/test/snippets.js |
@@ -83,22 +83,36 @@ |
["foo-2"] |
); |
test.done(); |
}; |
exports.testSnippetFiltersContainer = function(test) |
{ |
+ let events = []; |
+ |
+ function eventHandler(...args) |
+ { |
+ events.push([...args]); |
+ } |
+ |
function compareRules(description, domain, expectedMatches) |
{ |
let result = Snippets.getFiltersForDomain(domain); |
test.deepEqual(result.sort(), expectedMatches.sort(), description); |
} |
+ Snippets.on("snippets.filterAdded", |
+ eventHandler.bind(null, "snippets.filterAdded")); |
+ Snippets.on("snippets.filterRemoved", |
+ eventHandler.bind(null, "snippets.filterRemoved")); |
+ Snippets.on("snippets.filtersCleared", |
+ eventHandler.bind(null, "snippets.filtersCleared")); |
+ |
let domainFilter = Filter.fromText("example.com#$#filter1"); |
let subdomainFilter = Filter.fromText("www.example.com#$#filter2"); |
let otherDomainFilter = Filter.fromText("other.example.com#$#filter3"); |
Snippets.add(domainFilter); |
Snippets.add(subdomainFilter); |
Snippets.add(otherDomainFilter); |
compareRules( |
@@ -116,16 +130,25 @@ |
Snippets.clear(); |
compareRules( |
"Return no filters after clearing", |
"www.example.com", |
[] |
); |
+ test.deepEqual(events, [ |
+ ["snippets.filterAdded", domainFilter], |
+ ["snippets.filterAdded", subdomainFilter], |
+ ["snippets.filterAdded", otherDomainFilter], |
+ ["snippets.filterRemoved", domainFilter], |
+ ["snippets.filtersCleared"] |
+ ], |
+ "Event log"); |
+ |
test.done(); |
}; |
exports.testScriptParsing = function(test) |
{ |
function checkParsedScript(description, script, expectedTree) |
{ |
let tree = parseScript(script); |