Comparing version 0.11.0 to 0.11.1
@@ -16,4 +16,5 @@ exports["Browser"] = { | ||
exports["Node"] = { | ||
extends: "Browser", | ||
environment: "node" | ||
}; | ||
environment: "node", | ||
testHelpers: ["test/test-helper.js"], | ||
tests: ["test/*-test.js"] | ||
}; |
@@ -178,2 +178,4 @@ ((typeof define === "function" && define.amd && function (m) { | ||
referee.prepareMessage = msg; | ||
function actualAndExpectedMessageValues(actual, expected, message) { | ||
@@ -502,3 +504,4 @@ return [actual, expected, msg(message)]; | ||
err.name, | ||
err.message | ||
err.message, | ||
err.stack | ||
); | ||
@@ -519,3 +522,3 @@ } | ||
assert.exception.typeFailMessage = "${0}Expected ${1} but threw ${2} " + | ||
"(${3})"; | ||
"(${3})\n${4}"; | ||
assert.exception.matchFailMessage = "${0}Expected thrown ${1} (${2}) to " + | ||
@@ -522,0 +525,0 @@ "pass matcher function"; |
{ | ||
"name": "referee", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "Assertions for any JavaScript test framework and environment", | ||
"homepage": "http://busterjs.org/docs/referee", | ||
"author": { "name": "August Lilleaas and Christian Johansen" }, | ||
"author": "Christian Johansen", | ||
"contributors": [{ | ||
@@ -15,2 +15,11 @@ "name": "Christian Johansen", | ||
"url": "http://augustl.com" | ||
}, { | ||
"name": "Dave Geddes", | ||
"email": "davidcgeddes@gmail.com" | ||
}, { | ||
"name": "Malcolm Locke", | ||
"email": "malc@wholemeal.co.nz" | ||
}, { | ||
"name": "Stein Magnus Jodal", | ||
"email": "stein.magnus@jodal.no" | ||
}], | ||
@@ -23,6 +32,6 @@ "main": "./lib/referee", | ||
"scripts": { | ||
"test": "./node_modules/buster/bin/buster-test" | ||
"test": "./node_modules/buster/bin/buster-test --node" | ||
}, | ||
"dependencies": { | ||
"underscore": "~0.4", | ||
"lodash": "~0.4", | ||
"samsam": "~0.1", | ||
@@ -29,0 +38,0 @@ "bane": "~0.1" |
@@ -1,110 +0,113 @@ | ||
// if (typeof module === "object" && typeof require === "function") { | ||
// var assert = require("assert"); | ||
// var sinon = require("sinon"); | ||
// var testHelper = require("./test-helper"); | ||
// var buster = { util: require("buster-util") }; | ||
// var referee = require("../lib/referee"); | ||
// } | ||
/*jslint maxlen:160*/ | ||
(function (referee, testHelper, buster) { | ||
if (typeof require === "function" && typeof module === "object") { | ||
referee = require("../lib/referee"); | ||
testHelper = require("./test-helper"); | ||
buster = require("buster"); | ||
sinon = require("sinon"); | ||
} | ||
// var expect = referee.expect; | ||
var expect = referee.expect; | ||
// buster.util.testCase("ExpectTest", { | ||
// setUp: testHelper.setUp, | ||
// tearDown: testHelper.tearDown, | ||
buster.testCase("expect", { | ||
setUp: testHelper.setUp, | ||
tearDown: testHelper.tearDown, | ||
// "should be function": function () { | ||
// assert.equal(typeof expect, "function"); | ||
// }, | ||
"should be function": function () { | ||
assert.equals(typeof expect, "function"); | ||
}, | ||
// "should bind assert.equals to argument": function () { | ||
// assert.doesNotThrow(function () { | ||
// expect({}).toEqual({}); | ||
// }); | ||
// }, | ||
"should bind assert.equals to argument": function () { | ||
refute.exception(function () { | ||
expect({}).toEqual({}); | ||
}); | ||
}, | ||
// "should fail assertion if a not equals b": function () { | ||
// try { | ||
// expect({ id: 42 }).toEqual({ bleh: "Nah" }); | ||
// throw new Error("Did not throw"); | ||
// } catch (e) { | ||
// assert.equal(e.message, "[expect.toEqual] [object Object] " + | ||
// "expected to be equal to [object Object]"); | ||
// } | ||
// }, | ||
"should fail assertion if a not equals b": function () { | ||
try { | ||
expect({ id: 42 }).toEqual({ bleh: "Nah" }); | ||
throw new Error("Did not throw"); | ||
} catch (e) { | ||
assert.equals(e.message, "[expect.toEqual] [object Object] " + | ||
"expected to be equal to [object Object]"); | ||
} | ||
}, | ||
// "should fail assertion by calling buster.assert.fail": function () { | ||
// try { | ||
// expect({ id: 42 }).toEqual({ bleh: "Nah" }); | ||
// } catch (e) {} | ||
"should fail assertion by calling buster.assert.fail": function () { | ||
try { | ||
expect({ id: 42 }).toEqual({ bleh: "Nah" }); | ||
} catch (e) {} | ||
// assert.ok(referee.fail.calledOnce); | ||
// }, | ||
assert(referee.fail.calledOnce); | ||
}, | ||
// "should emit assertion pass event": function () { | ||
// var listener = sinon.spy(); | ||
// referee.on("pass", listener); | ||
"should emit assertion pass event": function () { | ||
var listener = sinon.spy(); | ||
referee.on("pass", listener); | ||
// expect({ id: 42 }).toEqual({ id: 42 }); | ||
expect({ id: 42 }).toEqual({ id: 42 }); | ||
// assert.ok(listener.calledOnce); | ||
// }, | ||
assert(listener.calledOnce); | ||
}, | ||
// "should emit assertion fail event": function () { | ||
// var listener = sinon.spy(); | ||
// referee.on("failure", listener); | ||
// referee.throwOnFailure = false; | ||
"should emit assertion fail event": function () { | ||
var listener = sinon.spy(); | ||
referee.on("failure", listener); | ||
referee.throwOnFailure = false; | ||
// expect({ id: 42 }).toEqual({ id: 22 }); | ||
expect({ id: 42 }).toEqual({ id: 22 }); | ||
// assert.ok(listener.calledOnce); | ||
// }, | ||
assert(listener.calledOnce); | ||
}, | ||
// "should expose refutation as expectation too": function () { | ||
// try { | ||
// expect({ id: 42 }).not.toEqual({ id: 42 }); | ||
// throw new Error("Did not throw"); | ||
// } catch (e) { | ||
// assert.equal(e.message, "[expect.not.toEqual] [object Object] " + | ||
// "expected not to be equal to [object Object]"); | ||
// } | ||
// }, | ||
"should expose refutation as expectation too": function () { | ||
try { | ||
expect({ id: 42 }).not.toEqual({ id: 42 }); | ||
throw new Error("Did not throw"); | ||
} catch (e) { | ||
assert.equals(e.message, "[expect.not.toEqual] [object Object] " + | ||
"expected not to be equal to [object Object]"); | ||
} | ||
}, | ||
// "should expose all assertions": function () { | ||
// var obj = { id: 42 }; | ||
"should expose all assertions": function () { | ||
var obj = { id: 42 }; | ||
// expect(obj).toBe(obj); | ||
// expect(obj).not.toBe({ id: 42 }); | ||
// expect(obj).toEqual({ id: 42 }); | ||
// expect(obj).not.toEqual({}); | ||
// expect(obj).toBeObject(); | ||
// expect(false).not.toBeObject(); | ||
// expect(function () {}).toBeFunction(); | ||
// expect({}).not.toBeFunction(); | ||
// expect(null).toBeDefined(); | ||
// expect(undefined).not.toBeDefined(); | ||
// expect(null).toBeNull(); | ||
// expect(42).not.toBeNull(); | ||
// expect(obj).toMatch({ id: 42 }); | ||
// expect(obj).not.toMatch({ id: 37 }); | ||
// expect(function () { | ||
// throw new TypeError("Oops"); | ||
// }).toThrow("TypeError"); | ||
// expect(function () {}).not.toThrow(); | ||
// expect({ tagName: "li" }).toHaveTagName("li"); | ||
// expect({ tagName: "ol" }).not.toHaveTagName("li"); | ||
// expect({ className: "a b c" }).toHaveClassName("b"); | ||
// expect({ className: "a b c" }).not.toHaveClassName("d"); | ||
// expect(true).toBeTruthy(); | ||
// expect(false).not.toBeTruthy(); | ||
// expect(false).toBeFalsy(); | ||
// expect(true).not.toBeFalsy(); | ||
// expect(3).toBeCloseTo(3, 0); | ||
// expect(2).not.toBeCloseTo(3, 0.5); | ||
// expect(2).toBeGreaterThan(1); | ||
// expect(1).not.toBeGreaterThan(2); | ||
// expect(1).toBeLessThan(2); | ||
// expect(2).not.toBeLessThan(1); | ||
// expect([0, 1, 2]).toContain(1); | ||
// expect([0, 1, 2]).not.toContain(3); | ||
// } | ||
// }); | ||
expect(obj).toBe(obj); | ||
expect(obj).not.toBe({ id: 42 }); | ||
expect(obj).toEqual({ id: 42 }); | ||
expect(obj).not.toEqual({}); | ||
expect(obj).toBeObject(); | ||
expect(false).not.toBeObject(); | ||
expect(function () {}).toBeFunction(); | ||
expect({}).not.toBeFunction(); | ||
expect(null).toBeDefined(); | ||
expect(undefined).not.toBeDefined(); | ||
expect(null).toBeNull(); | ||
expect(42).not.toBeNull(); | ||
expect(obj).toMatch({ id: 42 }); | ||
expect(obj).not.toMatch({ id: 37 }); | ||
expect(function () { | ||
throw new TypeError("Oops"); | ||
}).toThrow("TypeError"); | ||
expect(function () {}).not.toThrow(); | ||
expect({ tagName: "li" }).toHaveTagName("li"); | ||
expect({ tagName: "ol" }).not.toHaveTagName("li"); | ||
expect({ className: "a b c" }).toHaveClassName("b"); | ||
expect({ className: "a b c" }).not.toHaveClassName("d"); | ||
expect(true).toBeTruthy(); | ||
expect(false).not.toBeTruthy(); | ||
expect(false).toBeFalsy(); | ||
expect(true).not.toBeFalsy(); | ||
expect(3).toBeCloseTo(3, 0); | ||
expect(2).not.toBeCloseTo(3, 0.5); | ||
expect(2).toBeGreaterThan(1); | ||
expect(1).not.toBeGreaterThan(2); | ||
expect(1).toBeLessThan(2); | ||
expect(2).not.toBeLessThan(1); | ||
expect([0, 1, 2]).toContain(1); | ||
expect([0, 1, 2]).not.toContain(3); | ||
assert(true, "Avoid 'no assertions'"); | ||
} | ||
}); | ||
}(this.referee, this.testHelper, this.buster, this.sinon)); |
@@ -1106,20 +1106,2 @@ /*jslint maxlen:160*/ | ||
msg("fail with message when throwing wrong kind of exception", | ||
"[assert.exception] Expected [object Object] but threw Error (:()", | ||
function () { | ||
throw new Error(":("); | ||
}, { name: "TypeError" }).expectedFormats = 1; | ||
msg("fail with custom message when throwing wrong kind of exception", | ||
"[assert.exception] Wow: Expected [object Object] but threw Error (:()", | ||
function () { | ||
throw new Error(":("); | ||
}, { name: "TypeError" }, "Wow").expectedFormats = 1; | ||
msg("fail with custom message when throwing wrong message", | ||
"[assert.exception] Wow: Expected [object Object] but threw Error (:()", | ||
function () { | ||
throw new Error(":("); | ||
}, { name: "TypeError", message: "Aww" }, "Wow").expectedFormats = 1; | ||
pass("when matcher function returns true", function () { | ||
@@ -1147,2 +1129,30 @@ throw new TypeError("Aright"); | ||
buster.testCase("assert.exception unexpected exception", { | ||
"fails with custom message": function () { | ||
try { | ||
referee.assert.exception(function () { | ||
throw new Error(":("); | ||
}, { name: "TypeError" }, "Wow"); | ||
throw new Error("Expected to throw"); | ||
} catch (e) { | ||
assert.match(e.message, "[assert.exception] Wow: Expected " + | ||
"[object Object] but threw Error " + | ||
"(:()\nError: :(\n"); | ||
} | ||
}, | ||
"fails with custom message when message is wrong": function () { | ||
try { | ||
referee.assert.exception(function () { | ||
throw new Error(":("); | ||
}, { name: "Error", message: "Aww" }, "Wow"); | ||
throw new Error("Expected to throw"); | ||
} catch (e) { | ||
assert.match(e.message, "[assert.exception] Wow: Expected " + | ||
"[object Object] but threw " + | ||
"Error (:()\nError: :(\n"); | ||
} | ||
} | ||
}); | ||
testHelper.assertionTests("refute", "exception", function (pass, fail, msg) { | ||
@@ -1149,0 +1159,0 @@ fail("when callback throws", function () { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
105861
13
2239
94
+ Addedlodash@~0.4
- Removedunderscore@~0.4