Skip to content

Commit

Permalink
assert that the matcher is successfully created
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthropohedron committed Apr 5, 2015
1 parent 2a138c7 commit 48bb9f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/test-matcher-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var mock = require("./mock-channel.js");

exports["test exact host match"] = function(assert) {
var matcher = new Matcher([ "www.example.com" ]);
assert.ok(matcher, "Created matcher");
var channel = mock.createMockChannel("www.example.com", "/");
assert.strictEqual(matcher.testRequest(channel), true,
"Exact host match request");
Expand All @@ -13,26 +14,31 @@ exports["test exact host match"] = function(assert) {
exports["test partial host match"] = function(assert) {
var channel = mock.createMockChannel("www.example.com", "/");
var matcher = new Matcher([ "www." ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), true,
"Prefix host match request");
assert.strictEqual(matcher.testResponse(channel), true,
"Prefix host match response");
var matcher = new Matcher([ ".example.com" ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), true,
"Suffix host match request");
assert.strictEqual(matcher.testResponse(channel), true,
"Suffix host match response");
var matcher = new Matcher([ ".example." ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), true,
"Middle host match request");
assert.strictEqual(matcher.testResponse(channel), true,
"Middle host match response");
var matcher = new Matcher([ "www.exam*.com" ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), true,
"Glob host match request");
assert.strictEqual(matcher.testResponse(channel), true,
"Glob host match response");
var matcher = new Matcher([ "www.exa??le.com" ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), true,
"Wildcard host match request");
assert.strictEqual(matcher.testResponse(channel), true,
Expand All @@ -42,31 +48,37 @@ exports["test partial host match"] = function(assert) {
exports["test host nonmatch"] = function(assert) {
var channel = mock.createMockChannel("example.com", "/");
var matcher = new Matcher([ "www." ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), false,
"Prefix host nonmatch request");
assert.strictEqual(matcher.testResponse(channel), false,
"Prefix host nonmatch response");
var matcher = new Matcher([ "example.co" ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), false,
"Incomplete host nonmatch request");
assert.strictEqual(matcher.testResponse(channel), false,
"Incomplete host nonmatch response");
var matcher = new Matcher([ ".ample.com" ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), false,
"Suffix host nonmatch request");
assert.strictEqual(matcher.testResponse(channel), false,
"Suffix host nonmatch response");
var matcher = new Matcher([ ".exam." ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), false,
"Middle host nonmatch request");
assert.strictEqual(matcher.testResponse(channel), false,
"Middle host nonmatch response");
var matcher = new Matcher([ "*.example.com" ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), false,
"Glob host nonmatch request");
assert.strictEqual(matcher.testResponse(channel), false,
"Glob host nonmatch response");
var matcher = new Matcher([ "exa?mple.com" ]);
assert.ok(matcher, "Created matcher");
assert.strictEqual(matcher.testRequest(channel), false,
"Wildcard nonhost match request");
assert.strictEqual(matcher.testResponse(channel), false,
Expand Down
1 change: 1 addition & 0 deletions test/test-matcher-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var mock = require("./mock-channel.js");

exports["test exact path match"] = function(assert) {
var matcher = new Matcher([ "www.example.com/foo/bar$" ]);
assert.ok(matcher, "Created matcher");
var channel = mock.createMockChannel("www.example.com", "/foo/bar");
assert.strictEqual(matcher.testRequest(channel), true,
"Exact path match request");
Expand Down

0 comments on commit 48bb9f4

Please sign in to comment.