Skip to content

Commit

Permalink
First unit test, still to get passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-jack committed Nov 19, 2012
1 parent f7984ae commit b2472bb
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions spec/unit/cacheForeverExpecation.js
Expand Up @@ -2,8 +2,34 @@ var assert = require('chai').assert,
cacheForeverExpectation = lib.require('cacheForeverExpectation');

describe("when passed a value with no max-age", function() {
it("should throw an error", function() {
var runExpectation = cacheForeverExpectationWrapper("public,")
assert.throws(runExpectation, /The cache-control value \'public,\' should have contained a max-age./)
});
});

describe("when passed a value with no location", function() {
it("should throw an error", function() {
assert.throws(function() { cacheForeverExpectation })
var runExpectation = cacheForeverExpectationWrapper(",max-age=5000")
assert.throws(runExpectation, /The cache-control value \',max-age=5000\' should have matched/)
});
});

describe("when passed a value with max-age at end", function() {
it("should not throw an error", function() {
var runExpectation = cacheForeverExpectationWrapper("public, max-age=5000")
assert.doesNotThrow(runExpectation)
});
});
});

var cacheForeverExpectationWrapper = function cacheForeverExpectationWrapper(cacheControlHeader) {
return function() {
var fakeResponse = {
headers: {
'cache-control': cacheControlHeader
}
};

cacheForeverExpectation("public", fakeResponse)
}
}

0 comments on commit b2472bb

Please sign in to comment.