Skip to content

Commit

Permalink
another test, this time with some real matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthropohedron committed Apr 4, 2015
1 parent cbe8eed commit 0f7887a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/test-matcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
var Matcher = require("./matcher").Matcher;

function MockChannel(host, path) {
this.URI = {
host: host,
path: path
};
}

function createMockChannel(host, path) {
return new MockChannel(host, path);
}

exports["test create matcher"] = function(assert) {
var patterns = [
"TAG:^Content-Type: image/",
Expand Down Expand Up @@ -33,4 +44,13 @@ exports["test create match invalid pattern"] = function(assert) {
}, /invalid pattern/i, "Invalid pattern passed to Matcher constructor");
};

exports["test exact host match"] = function(assert) {
var matcher = new Matcher([ "www.example.com" ]);
var channel = createMockChannel("www.example.com", "/");
assert.strictEqual(matcher.testRequest(channel), true,
"Exact host match request");
assert.strictEqual(matcher.testResponse(channel), true,
"Exact host match response");
}

require("sdk/test").run(exports);

0 comments on commit 0f7887a

Please sign in to comment.