[Pkg-javascript-commits] [node-lolex] 05/12: embed test deps
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Sat Feb 10 19:02:55 UTC 2018
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository node-lolex.
commit 5a1d10ab635384da92cecd2ba071eb85743a69f9
Author: Pirate Praveen <praveen at debian.org>
Date: Sun Feb 11 00:07:33 2018 +0530
embed test deps
---
debian/node_modules/bane/.npmignore | 3 +
debian/node_modules/bane/.travis.yml | 9 +
debian/node_modules/bane/AUTHORS | 3 +
debian/node_modules/bane/LICENSE | 25 +
debian/node_modules/bane/Readme.md | 115 ++
debian/node_modules/bane/autolint.js | 19 +
debian/node_modules/bane/buster.js | 9 +
debian/node_modules/bane/lib/bane.js | 174 +++
debian/node_modules/bane/package.json | 37 +
debian/node_modules/bane/test/bane-test.js | 446 ++++++
debian/node_modules/referee/.npmignore | 3 +
debian/node_modules/referee/.travis.yml | 9 +
debian/node_modules/referee/AUTHORS | 6 +
debian/node_modules/referee/Gruntfile.js | 24 +
debian/node_modules/referee/LICENSE | 27 +
debian/node_modules/referee/Readme.md | 57 +
debian/node_modules/referee/autolint.js | 22 +
debian/node_modules/referee/buster.js | 26 +
debian/node_modules/referee/lib/expect.js | 67 +
debian/node_modules/referee/lib/referee.js | 716 +++++++++
debian/node_modules/referee/package.json | 54 +
debian/node_modules/referee/test/expect-test.js | 115 ++
debian/node_modules/referee/test/referee-test.js | 1725 ++++++++++++++++++++++
debian/node_modules/referee/test/test-helper.js | 206 +++
24 files changed, 3897 insertions(+)
diff --git a/debian/node_modules/bane/.npmignore b/debian/node_modules/bane/.npmignore
new file mode 100644
index 0000000..edcce2e
--- /dev/null
+++ b/debian/node_modules/bane/.npmignore
@@ -0,0 +1,3 @@
+*.log
+node_modules
+.idea
diff --git a/debian/node_modules/bane/.travis.yml b/debian/node_modules/bane/.travis.yml
new file mode 100644
index 0000000..896e270
--- /dev/null
+++ b/debian/node_modules/bane/.travis.yml
@@ -0,0 +1,9 @@
+language: node_js
+sudo: false
+node_js:
+ - "0.10"
+ - "0.12"
+ - "4"
+ - "5"
+before_install:
+ - npm i -g npm
diff --git a/debian/node_modules/bane/AUTHORS b/debian/node_modules/bane/AUTHORS
new file mode 100644
index 0000000..a4662f7
--- /dev/null
+++ b/debian/node_modules/bane/AUTHORS
@@ -0,0 +1,3 @@
+Christian Johansen (christian at cjohansen.no)
+August Lilleaas (august at augustl.com)
+Stein Magnus Jodal (stein.magnus at jodal.no)
\ No newline at end of file
diff --git a/debian/node_modules/bane/LICENSE b/debian/node_modules/bane/LICENSE
new file mode 100644
index 0000000..f956925
--- /dev/null
+++ b/debian/node_modules/bane/LICENSE
@@ -0,0 +1,25 @@
+(The BSD License)
+
+Copyright (c) 2010-2013, Christian Johansen, christian at cjohansen.no and
+Stein Magnus Jodal, stein.magnus at jodal.no. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/debian/node_modules/bane/Readme.md b/debian/node_modules/bane/Readme.md
new file mode 100644
index 0000000..950cfe0
--- /dev/null
+++ b/debian/node_modules/bane/Readme.md
@@ -0,0 +1,115 @@
+# BANE
+
+[![Build status](https://secure.travis-ci.org/busterjs/bane.png?branch=master)](http://travis-ci.org/busterjs/bane)
+
+> Browser globals, AMD and Node Events
+
+`bane` is a small event emitter library that works in browsers (including old
+and rowdy ones, like IE6) and Node. It will define itself as an AMD module if
+you want it to (i.e. if there's a `define` function available).
+
+`bane` is not entirely API compatible with Node's event emitter, but it does
+provide the iconic `on` and `emit` functions.
+
+## Developers - Running tests
+
+```
+npm install
+./node_modules/buster/bin/buster-test --node
+./node_modules/buster/bin/buster-server
+./node_modules/buster/bin/buster-test --browser
+```
+
+## Emitter creation API
+
+### `var emitter = bane.createEventEmitter([object]);`
+
+
+Create a new event emitter. If an object is passed, it will be modified by
+adding the event emitter methods (see below).
+
+## Emitter API
+
+
+### `on(event, listener)`
+
+Register the `listener` function to be called when the emitter emits the
+`event` (which is a string).
+
+### `on(listener)`
+
+Register the `listener` function as a "supervisor". It will be called for
+any event emitted from the emitter.
+
+### `off(event, listener)`
+
+Remove a previously registered `listener` function for the specified `event`
+(which is a string). If the function has not previously been registered, it is
+silently ignored.
+
+### `off(listener)`
+
+Remove a previously registered "supervisor" `listener` function. If the
+function has not previously been registered, it is silently ignored.
+
+###`off(event)`
+
+Remove all previously registered `listener` functions for the specified
+`event` (which is a string). If no functions have previously been registered,
+it is silently ignored.
+
+###`off()`
+
+Remove all previously registered listeners on the object, both regular
+listeners, supervisor listeners, and errbacks. If no functions have previously
+been registrered, it is silently ignored.
+
+###`once(event, listener)`
+
+Register a `listener` function for the given `event` (which is a string)
+only once. After the first event has been emitted, the listener is removed.
+
+###`bind(object)`
+
+Register all methods on `object` as listeners for the event named as the
+method name. Convenient way to bind many event listeners in one go:
+
+```javascript
+var listener = {
+ start: function () {
+ console.log("Started!");
+ },
+
+ end: function () {
+ console.log("Ended");
+ }
+};
+
+emitter.bind(listener);
+```
+
+The above example will bind `listener.start` to the `"start"` event and vice
+versa with `end`. Note that property names can be quoted to bind to any kind of
+event name (e.g. `"test:start"`).
+
+### `bind(object, events)`
+
+Binds methods on `object` to corresponding events (see `bind(object)`
+above), but instead of binding all methods on the object, only binds the
+events listed in the provided `events` array.
+
+###`errback(listener)`
+
+Register the `listener` function as an "errback". It will be called with the
+arguments `event` and `error` for any error thrown when listeners are
+notified.
+
+### `emit(event[, data1[, data2[, ...]]])`
+
+Emit the `event` (which is a string) with optional data. Will cause all
+registered listeners for the named event to be called. If additional arguments
+are provided, the listeners will be called with them.
+
+## License
+
+Two-clause BSD-license, see [LICENSE](https://raw.github.com/busterjs/bane/master/LICENSE)
diff --git a/debian/node_modules/bane/autolint.js b/debian/node_modules/bane/autolint.js
new file mode 100644
index 0000000..dadbf36
--- /dev/null
+++ b/debian/node_modules/bane/autolint.js
@@ -0,0 +1,19 @@
+module.exports = {
+ paths: [
+ "lib/*.js",
+ "test/*.js"
+ ],
+ linterOptions: {
+ node: true,
+ browser: true,
+ plusplus: true,
+ sloppy: true,
+ vars: true,
+ predef: [
+ "define",
+ "assert",
+ "refute",
+ "buster"
+ ]
+ }
+};
diff --git a/debian/node_modules/bane/buster.js b/debian/node_modules/bane/buster.js
new file mode 100644
index 0000000..5821888
--- /dev/null
+++ b/debian/node_modules/bane/buster.js
@@ -0,0 +1,9 @@
+exports.Browsers = {
+ sources: ["lib/bane.js"],
+ tests: ["test/bane-test.js"]
+};
+
+exports.Node = {
+ extends: "Browsers",
+ environment: "node"
+};
diff --git a/debian/node_modules/bane/lib/bane.js b/debian/node_modules/bane/lib/bane.js
new file mode 100644
index 0000000..1f8feed
--- /dev/null
+++ b/debian/node_modules/bane/lib/bane.js
@@ -0,0 +1,174 @@
+((typeof define === "function" && define.amd && function (m) { define("bane", m); }) ||
+ (typeof module === "object" && function (m) { module.exports = m(); }) ||
+ function (m) { this.bane = m(); }
+)(function () {
+ "use strict";
+ var slice = Array.prototype.slice;
+
+ function handleError(event, error, errbacks) {
+ var i, l = errbacks.length;
+ if (l > 0) {
+ for (i = 0; i < l; ++i) { errbacks[i](event, error); }
+ return;
+ }
+ setTimeout(function () {
+ error.message = event + " listener threw error: " + error.message;
+ throw error;
+ }, 0);
+ }
+
+ function assertFunction(fn) {
+ if (typeof fn !== "function") {
+ throw new TypeError("Listener is not function");
+ }
+ return fn;
+ }
+
+ function supervisors(object) {
+ if (!object.supervisors) { object.supervisors = []; }
+ return object.supervisors;
+ }
+
+ function listeners(object, event) {
+ if (!object.listeners) { object.listeners = {}; }
+ if (event && !object.listeners[event]) { object.listeners[event] = []; }
+ return event ? object.listeners[event] : object.listeners;
+ }
+
+ function errbacks(object) {
+ if (!object.errbacks) { object.errbacks = []; }
+ return object.errbacks;
+ }
+
+ /**
+ * @signature var emitter = bane.createEmitter([object]);
+ *
+ * Create a new event emitter. If an object is passed, it will be modified
+ * by adding the event emitter methods (see below).
+ */
+ function createEventEmitter(object) {
+ object = object || {};
+
+ function notifyListener(event, listener, args) {
+ try {
+ listener.listener.apply(listener.thisp || object, args);
+ } catch (e) {
+ handleError(event, e, errbacks(object));
+ }
+ }
+
+ object.on = function (event, listener, thisp) {
+ if (typeof event === "function") {
+ return supervisors(this).push({
+ listener: event,
+ thisp: listener
+ });
+ }
+ listeners(this, event).push({
+ listener: assertFunction(listener),
+ thisp: thisp
+ });
+ };
+
+ object.off = function (event, listener) {
+ var fns, events, i, l;
+ if (!event) {
+ fns = supervisors(this);
+ fns.splice(0, fns.length);
+
+ events = listeners(this);
+ for (i in events) {
+ if (events.hasOwnProperty(i)) {
+ fns = listeners(this, i);
+ fns.splice(0, fns.length);
+ }
+ }
+
+ fns = errbacks(this);
+ fns.splice(0, fns.length);
+
+ return;
+ }
+ if (typeof event === "function") {
+ fns = supervisors(this);
+ listener = event;
+ } else {
+ fns = listeners(this, event);
+ }
+ if (!listener) {
+ fns.splice(0, fns.length);
+ return;
+ }
+ for (i = 0, l = fns.length; i < l; ++i) {
+ if (fns[i].listener === listener) {
+ fns.splice(i, 1);
+ return;
+ }
+ }
+ };
+
+ object.once = function (event, listener, thisp) {
+ var wrapper = function () {
+ object.off(event, wrapper);
+ listener.apply(this, arguments);
+ };
+
+ object.on(event, wrapper, thisp);
+ };
+
+ object.bind = function (object, events) {
+ var prop, i, l;
+ if (!events) {
+ for (prop in object) {
+ if (typeof object[prop] === "function") {
+ this.on(prop, object[prop], object);
+ }
+ }
+ } else {
+ for (i = 0, l = events.length; i < l; ++i) {
+ if (typeof object[events[i]] === "function") {
+ this.on(events[i], object[events[i]], object);
+ } else {
+ throw new Error("No such method " + events[i]);
+ }
+ }
+ }
+ return object;
+ };
+
+ object.emit = function (event) {
+ var toNotify = supervisors(this);
+ var args = slice.call(arguments), i, l;
+
+ for (i = 0, l = toNotify.length; i < l; ++i) {
+ notifyListener(event, toNotify[i], args);
+ }
+
+ toNotify = listeners(this, event).slice();
+ args = slice.call(arguments, 1);
+ for (i = 0, l = toNotify.length; i < l; ++i) {
+ notifyListener(event, toNotify[i], args);
+ }
+ };
+
+ object.errback = function (listener) {
+ if (!this.errbacks) { this.errbacks = []; }
+ this.errbacks.push(assertFunction(listener));
+ };
+
+ return object;
+ }
+
+ return {
+ createEventEmitter: createEventEmitter,
+ aggregate: function (emitters) {
+ var aggregate = createEventEmitter();
+ emitters.forEach(function (emitter) {
+ emitter.on(function (event, data) {
+ aggregate.emit(event, data);
+ });
+ });
+ return aggregate;
+ }
+ };
+});
diff --git a/debian/node_modules/bane/package.json b/debian/node_modules/bane/package.json
new file mode 100644
index 0000000..dddf44c
--- /dev/null
+++ b/debian/node_modules/bane/package.json
@@ -0,0 +1,37 @@
+{
+ "name": "bane",
+ "version": "1.1.2",
+ "description": "(Yet another) Event emitter for Node, Browser globals and AMD",
+ "homepage": "http://busterjs.org/docs/bane/",
+ "author": "August Lilleaas and Christian Johansen",
+ "contributors": [
+ {
+ "name": "Christian Johansen",
+ "email": "christian at cjohansen.no",
+ "url": "http://cjohansen.no"
+ },
+ {
+ "name": "August Lilleaas",
+ "email": "august.lilleaas at gmail.com",
+ "url": "http://augustl.com"
+ },
+ {
+ "name": "Stein Magnus Jodal",
+ "email": "stein.magnus at jodal.no",
+ "url": "http://jodal.no"
+ }
+ ],
+ "license": "BSD-2-Clause",
+ "main": "./lib/bane",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/busterjs/bane.git"
+ },
+ "scripts": {
+ "test": "node node_modules/buster/bin/buster-test",
+ "test-debug": "node --debug-brk node_modules/buster/bin/buster-test"
+ },
+ "devDependencies": {
+ "buster": "0.7.x"
+ }
+}
diff --git a/debian/node_modules/bane/test/bane-test.js b/debian/node_modules/bane/test/bane-test.js
new file mode 100644
index 0000000..6715c1d
--- /dev/null
+++ b/debian/node_modules/bane/test/bane-test.js
@@ -0,0 +1,446 @@
+if (typeof module === "object" && typeof require === "function") {
+ var buster = require("buster");
+ var bane = require("../lib/bane");
+}
+
+var assert = buster.assert;
+var refute = buster.refute;
+
+buster.testCase("bane", {
+ ".create": {
+ "returns event emitter": function () {
+ var emitter = bane.createEventEmitter();
+
+ assert.isObject(emitter);
+ assert.isFunction(emitter.on);
+ assert.isFunction(emitter.emit);
+ },
+
+ "returns and extends existing object": function () {
+ var object = {};
+ var emitter = bane.createEventEmitter(object);
+
+ assert.same(object, emitter);
+ assert.isFunction(emitter.on);
+ assert.isFunction(emitter.emit);
+ }
+ },
+
+ ".on": {
+ "throws for uncallable listener": function () {
+ var emitter = bane.createEventEmitter();
+
+ assert.exception(function () {
+ emitter.on("event", {});
+ });
+ },
+
+ "supervisor is notified of all events": function () {
+ var supervisor = this.spy();
+ var emitter = bane.createEventEmitter();
+
+ emitter.on(supervisor);
+ emitter.emit("something", 42);
+ emitter.emit("stuff", { id: 13 });
+
+ assert.calledTwice(supervisor);
+ assert.calledWith(supervisor, "something", 42);
+ }
+ },
+
+ ".errback": {
+ "fails when passing non-function": function () {
+ var emitter = bane.createEventEmitter();
+ assert.exception(function () {
+ emitter.errback({});
+ });
+ }
+ },
+
+ ".emit": {
+ "calls all listeners": function () {
+ var emitter = bane.createEventEmitter();
+ var listeners = [this.spy(), this.spy()];
+ emitter.on("event", listeners[0]);
+ emitter.on("event", listeners[1]);
+
+ emitter.emit("event");
+
+ assert.called(listeners[0]);
+ assert.called(listeners[1]);
+ },
+
+ "calls all listeners with correct this object": function () {
+ var emitter = bane.createEventEmitter();
+ var listeners = [this.spy(), this.spy()];
+ var obj = {};
+ emitter.on("event", listeners[0], obj);
+ emitter.on("event", listeners[1]);
+
+ emitter.emit("event");
+
+ assert.calledOn(listeners[0], obj);
+ assert.calledOn(listeners[1], emitter);
+ },
+
+ "passes through arguments": function () {
+ var emitter = bane.createEventEmitter();
+ var listener = this.spy();
+
+ emitter.on("event", listener);
+ emitter.emit("event", "String", 1, 32);
+
+ assert.calledWith(listener, "String", 1, 32);
+ },
+
+ "emits all even when some fail": function () {
+ var emitter = bane.createEventEmitter();
+ var listeners = [
+ this.stub().throws("I'm thrown on purpose"),
+ this.spy()
+ ];
+
+ emitter.on("event", listeners[0]);
+ emitter.on("event", listeners[1]);
+
+ emitter.emit("event");
+
+ assert.called(listeners[1]);
+ },
+
+ "passes error to errback": function () {
+ var emitter = bane.createEventEmitter();
+ var errback = this.spy();
+ emitter.errback(errback);
+
+ emitter.on("event", this.stub().throws());
+ emitter.emit("event");
+
+ assert.calledOnce(errback);
+ },
+
+ "calls listeners in the order they were added": function () {
+ var emitter = bane.createEventEmitter();
+ var listeners = [this.spy(), this.spy()];
+
+ emitter.on("event", listeners[0]);
+ emitter.on("event", listeners[1]);
+
+ emitter.emit("event");
+
+ assert.callOrder(listeners[0], listeners[1]);
+ },
+
+ "calls supervisors before other listeners": function () {
+ var emitter = bane.createEventEmitter();
+ var supervisors = [this.spy(), this.spy()];
+ var listeners = [this.spy(), this.spy()];
+
+ emitter.on("event", listeners[0]);
+ emitter.on("event", listeners[1]);
+ emitter.on(supervisors[0]);
+ emitter.on(supervisors[1]);
+
+ emitter.emit("event");
+
+ assert.callOrder(
+ supervisors[0], supervisors[1], listeners[0], listeners[1]);
+ },
+
+ "does not fail if no listeners": function () {
+ var emitter = bane.createEventEmitter();
+
+ refute.exception(function () {
+ emitter.emit("event");
+ });
+ },
+
+ "only notifies relevant listeners": function () {
+ var emitter = bane.createEventEmitter();
+ var listeners = [this.spy(), this.spy()];
+
+ emitter.on("event", listeners[0]);
+ emitter.on("other", listeners[1]);
+
+ emitter.emit("other");
+
+ assert.called(listeners[1]);
+ refute.called(listeners[0]);
+ },
+
+ // AKA "creates extensible emitters"
+ "does not emit events to other emitter's listeners": function () {
+ function Thing() {}
+ Thing.prototype = bane.createEventEmitter();
+ var emitter1 = new Thing();
+ var emitter2 = new Thing();
+ var listener = this.spy();
+ emitter1.on("ouch", listener);
+
+ emitter2.emit("ouch");
+
+ refute.called(listener);
+ }
+ },
+
+ ".bind": {
+ "returns object bound to": function () {
+ var listener = { doIt: function () {} };
+ var result = bane.createEventEmitter().bind(listener, ["doIt"]);
+
+ assert.same(result, listener);
+ },
+
+ "binds to method named after event": function () {
+ var emitter = bane.createEventEmitter();
+ var listener = { doIt: this.spy() };
+
+ emitter.bind(listener);
+ emitter.emit("doIt", 42);
+
+ assert.calledOnceWith(listener.doIt, 42);
+ assert.calledOn(listener.doIt, listener);
+ },
+
+ "binds all methods as listeners to corresponding events": function () {
+ var emitter = bane.createEventEmitter();
+ var listener = {
+ complete: this.spy(),
+ failure: this.spy(),
+ success: this.spy()
+ };
+
+ emitter.bind(listener);
+ emitter.emit("complete");
+ emitter.emit("failure");
+ emitter.emit("success");
+
+ assert.calledOnce(listener.complete);
+ assert.calledOnce(listener.failure);
+ assert.calledOnce(listener.success);
+ },
+
+ "binds inherited methods": function () {
+ var emitter = bane.createEventEmitter();
+ function F() {}
+ F.prototype = { something: this.spy() };
+ var listener = new F();
+ listener.failure = function () {};
+
+ emitter.bind(listener);
+ emitter.emit("something");
+
+ assert.calledOnce(F.prototype.something);
+ },
+
+ "binds array of methods/events": function () {
+ var emitter = bane.createEventEmitter();
+ var listener = {
+ one: this.spy(),
+ two: this.spy(),
+ three: this.spy()
+ };
+
+ emitter.bind(listener, ["one", "three"]);
+ emitter.emit("one");
+ emitter.emit("two");
+ emitter.emit("three");
+
+ assert.called(listener.one);
+ assert.calledOn(listener.one, listener);
+ refute.called(listener.two);
+ assert.called(listener.three);
+ },
+
+ "fails array when binding non-existent method": function () {
+ var emitter = bane.createEventEmitter();
+ var listener = {};
+
+ assert.exception(function () {
+ emitter.bind(listener, ["one"]);
+ });
+ }
+ },
+
+ ".off": {
+ "removes listener": function () {
+ var listener = this.spy();
+ var emitter = bane.createEventEmitter();
+
+ emitter.on("event", listener);
+ emitter.off("event", listener);
+ emitter.emit("event");
+
+ refute.called(listener);
+ },
+
+ "removes supervisor listener": function () {
+ var supervisor = this.spy();
+ var emitter = bane.createEventEmitter();
+
+ emitter.on(supervisor);
+ emitter.off(supervisor);
+ emitter.emit("something", 42);
+ emitter.emit("stuff", { id: 13 });
+
+ refute.called(supervisor);
+ },
+
+ "should not remove listener for other event": function () {
+ var listener = this.spy();
+ var emitter = bane.createEventEmitter();
+
+ emitter.on("event", listener);
+ emitter.off("event2", listener);
+ emitter.emit("event");
+ emitter.emit("event2");
+
+ assert.calledOnce(listener);
+ },
+
+ "should not remove other listeners": function () {
+ var listeners = [this.spy(), this.spy(), this.spy()];
+ var emitter = bane.createEventEmitter();
+
+ emitter.on("event", listeners[0]);
+ emitter.on("event", listeners[1]);
+ emitter.on("event", listeners[2]);
+ emitter.off("event", listeners[1]);
+ emitter.emit("event");
+
+ assert.calledOnce(listeners[0]);
+ refute.called(listeners[1]);
+ assert.calledOnce(listeners[2]);
+ },
+
+ "without listener should remove all listeners": function () {
+ var listeners = [this.spy(), this.spy(), this.spy()];
+ var emitter = bane.createEventEmitter();
+
+ emitter.on("event", listeners[0]);
+ emitter.on("event", listeners[1]);
+ emitter.on("event", listeners[2]);
+ emitter.off("event");
+ emitter.emit("event");
+
+ refute.called(listeners[0]);
+ refute.called(listeners[1]);
+ refute.called(listeners[2]);
+ },
+
+ "without any args removes all supervisors": function () {
+ var supervisors = [this.spy(), this.spy()];
+ var emitter = bane.createEventEmitter();
+
+ emitter.on(supervisors[0]);
+ emitter.on(supervisors[1]);
+ emitter.off();
+ emitter.emit("event1");
+ emitter.emit("event2");
+
+ refute.called(supervisors[0]);
+ refute.called(supervisors[1]);
+ },
+
+ "without any args removes all listeners": function () {
+ var listeners = [this.spy(), this.spy()];
+ var emitter = bane.createEventEmitter();
+
+ emitter.on("event1", listeners[0]);
+ emitter.on("event2", listeners[1]);
+ emitter.off();
+ emitter.emit("event1");
+ emitter.emit("event2");
+
+ refute.called(listeners[0]);
+ refute.called(listeners[1]);
+ },
+
+ "without any args removes all errbacks": function() {
+ var emitter = bane.createEventEmitter();
+ var errback = this.spy();
+ emitter.errback(errback);
+
+ emitter.on("event", this.stub().throws());
+ emitter.off();
+ emitter.emit("event");
+
+ refute.called(errback);
+ },
+
+ "should remove listener in other listener for same event": function () {
+ var emitter = bane.createEventEmitter();
+ var listener = this.spy();
+
+ emitter.on("foo", function () {
+ emitter.off("foo", listener);
+ });
+ emitter.on("foo", listener);
+ emitter.emit("foo");
+ emitter.emit("foo");
+
+ assert.calledOnce(listener);
+ }
+ },
+
+ ".once": {
+ "is only called once": function () {
+ var listener = this.spy();
+ var emitter = bane.createEventEmitter();
+
+ emitter.once("event", listener);
+ emitter.emit("event");
+ emitter.emit("event");
+
+ assert.calledOnce(listener);
+ },
+
+ "is called with emitted arguments": function () {
+ var listener = this.spy();
+ var emitter = bane.createEventEmitter();
+
+ emitter.once("event", listener);
+ emitter.emit("event", "foo", 1);
+
+ assert.calledWithExactly(listener, "foo", 1);
+ },
+
+ "is called with context": function () {
+ var emitter = bane.createEventEmitter();
+ var listener = function () { this.foo = "bar"; };
+ var obj = {};
+
+ emitter.on("event", listener, obj);
+ emitter.emit("event");
+
+ assert.equals("bar", obj.foo);
+ }
+ },
+
+ ".aggregate": {
+ "proxies events": function () {
+ var emitter = bane.createEventEmitter();
+ var listener = this.spy();
+
+ var aggregated = bane.aggregate([emitter]);
+ aggregated.on("something", listener);
+ emitter.emit("something");
+
+ assert.calledOnce(listener);
+ },
+
+ "proxies multiple event emitters": function () {
+ var emitter1 = bane.createEventEmitter();
+ var emitter2 = bane.createEventEmitter();
+ var listener = this.spy();
+
+ var aggregated = bane.aggregate([emitter1, emitter2]);
+ aggregated.on("some-other-thing", listener);
+
+ emitter1.emit("some-other-thing");
+ emitter2.emit("some-other-thing");
+
+ assert.calledTwice(listener);
+ }
+ }
+});
diff --git a/debian/node_modules/referee/.npmignore b/debian/node_modules/referee/.npmignore
new file mode 100644
index 0000000..edcce2e
--- /dev/null
+++ b/debian/node_modules/referee/.npmignore
@@ -0,0 +1,3 @@
+*.log
+node_modules
+.idea
diff --git a/debian/node_modules/referee/.travis.yml b/debian/node_modules/referee/.travis.yml
new file mode 100644
index 0000000..896e270
--- /dev/null
+++ b/debian/node_modules/referee/.travis.yml
@@ -0,0 +1,9 @@
+language: node_js
+sudo: false
+node_js:
+ - "0.10"
+ - "0.12"
+ - "4"
+ - "5"
+before_install:
+ - npm i -g npm
diff --git a/debian/node_modules/referee/AUTHORS b/debian/node_modules/referee/AUTHORS
new file mode 100644
index 0000000..2c1eebc
--- /dev/null
+++ b/debian/node_modules/referee/AUTHORS
@@ -0,0 +1,6 @@
+Christian Johansen, christian at cjohansen.no
+August Lilleaas, august.lilleaas at gmail.com
+Dave Geddes davidcgeddes at gmail.com
+Malcolm Locke malc at wholemeal.co.nz
+Stein Magnus Jodal stein.magnus at jodal.no
+Balazs Ree ree at greenfinity.hu
diff --git a/debian/node_modules/referee/Gruntfile.js b/debian/node_modules/referee/Gruntfile.js
new file mode 100644
index 0000000..617cac3
--- /dev/null
+++ b/debian/node_modules/referee/Gruntfile.js
@@ -0,0 +1,24 @@
+module.exports = function (grunt) {
+
+ grunt.loadNpmTasks("grunt-buster");
+
+ grunt.initConfig({
+ "buster": {
+ "browser": {
+ "test": {
+ "config-group": "browser"
+ }
+ },
+ "node": {
+ "test": {
+ "config-group": "node"
+ }
+ }
+ }
+ });
+
+ grunt.registerTask("test", "Clean build, minify and run tests",
+ ["buster:node:test", "buster:browser:server", "buster:browser:phantomjs", "buster:browser:test"]
+ );
+
+};
diff --git a/debian/node_modules/referee/LICENSE b/debian/node_modules/referee/LICENSE
new file mode 100644
index 0000000..f00310b
--- /dev/null
+++ b/debian/node_modules/referee/LICENSE
@@ -0,0 +1,27 @@
+(The BSD License)
+
+Copyright (c) 2010-2012, Christian Johansen, christian at cjohansen.no and
+August Lilleaas, august.lilleaas at gmail.com. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Christian Johansen nor the names of his contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/debian/node_modules/referee/Readme.md b/debian/node_modules/referee/Readme.md
new file mode 100644
index 0000000..7af4a5c
--- /dev/null
+++ b/debian/node_modules/referee/Readme.md
@@ -0,0 +1,57 @@
+# referee
+
+[![Build status](https://secure.travis-ci.org/busterjs/referee.png?branch=master)](http://travis-ci.org/busterjs/referee)
+
+**referee** is in your unit tests, deciding who passes and who fails.
+
+It is a test-framework agnostic assertion and expectation library.
+Some highlights:
+
+- Rich library of assertions
+- Symmetric assert/refute (refute is **referee**'s "assert.not*")
+- Evented: Emits success and failure events
+- Failing assertions throw exceptions by default, but can be configured to not
+- API to add custom assertions that provides quite a bit of plumbing for free
+
+Full documentation:
+[docs.busterjs.org/en/latest/modules/referee](http://docs.busterjs.org/en/latest/modules/referee/).
+
+**referee** works in browsers (including old and rowdy ones, like IE6) and Node.
+It will define itself as an AMD module if you want it to (i.e. if there's a
+`define` function available).
+
+
+## Changelog
+
+**1.2.0** (2015-Nov-16)
+
+* Updated dependencies [#13](https://github.com/busterjs/referee/pull/13)
+* Added license info in package.json [#12](https://github.com/busterjs/referee/pull/12)
+* A `test` method on assertions, returning a promise which is resolved, when assertion passes, and rejected when it fails; relies on a `Promise` global (shimmable) [#9](https://github.com/busterjs/referee/pull/9)
+
+**1.1.1** (2014-Dec-12)
+
+* part of fix for issue [#274 - quoting in assertion failures](https://github.com/busterjs/buster/issues/274)
+
+**1.1.0** (2014-Oct-31)
+
+* fix for issue [#402 - referee.expect fails if path.resolve gets stubbed](https://github.com/busterjs/buster/issues/402)
+
+**1.0.3** (2014-Apr-30)
+
+* fix for issue [#387 - Referee: assert.exception does not check exception type (when given as string)](https://github.com/busterjs/buster/issues/387)
+
+
+## Developers - Running tests
+
+### Node
+
+ 1. `npm install` - installs dev dependencies
+ 1. `npm test` - runs node tests
+
+### Browsers
+
+ 1. `npm install` - installs dev dependencies
+ 1. `npm start` - starts buster server
+ 1. open url [localhost:1111/capture](http://localhost:1111/capture) in the browser(s) you want to test with
+ 1. `npm run-script test-browser` - runs browser tests
diff --git a/debian/node_modules/referee/autolint.js b/debian/node_modules/referee/autolint.js
new file mode 100644
index 0000000..7a8ac1c
--- /dev/null
+++ b/debian/node_modules/referee/autolint.js
@@ -0,0 +1,22 @@
+module.exports = {
+ linter: "jshint",
+ paths: [
+ "lib/**/*.js",
+ "test/**/*.js"
+ ],
+ linterOptions: {
+ node: true,
+ browser: true,
+ plusplus: false,
+ strict: false,
+ onevar: false,
+ nomen: false,
+ regexp: true,
+ predef: [
+ "define",
+ "assert",
+ "refute",
+ "buster"
+ ]
+ }
+};
diff --git a/debian/node_modules/referee/buster.js b/debian/node_modules/referee/buster.js
new file mode 100644
index 0000000..88b33dc
--- /dev/null
+++ b/debian/node_modules/referee/buster.js
@@ -0,0 +1,26 @@
+exports["browser"] = {
+ environment: "browser",
+ libs: [
+ "node_modules/when/es6-shim/Promise.js",
+ "node_modules/lodash/index.js",
+ "node_modules/samsam/lib/samsam.js",
+ "node_modules/bane/lib/bane.js"
+ ],
+ sources: [
+ "lib/expect.js",
+ "lib/referee.js"
+ ],
+ testHelpers: ["test/test-helper.js"],
+ tests: ["test/*-test.js"]
+};
+
+exports["node"] = {
+ environment: "node",
+ testHelpers: [
+ "node_modules/when/es6-shim/Promise.js",
+ "test/test-helper.js"
+ ],
+ tests: [
+ "test/*-test.js"
+ ]
+};
diff --git a/debian/node_modules/referee/lib/expect.js b/debian/node_modules/referee/lib/expect.js
new file mode 100644
index 0000000..4e69e51
--- /dev/null
+++ b/debian/node_modules/referee/lib/expect.js
@@ -0,0 +1,67 @@
+((typeof define === "function" && define.amd && function (m) {
+ define("expect", ["lodash"], m);
+}) || (typeof module === "object" && function (m) {
+ module.exports = m(require("lodash"));
+}) || function (m) { this.expect = m(this._); }
+)(function (_) {
+ var expectation = {};
+ function F() {}
+ var create = function (object) { F.prototype = object; return new F(); };
+
+ var expect = function (actual) {
+ var expectation = _.extend(create(expect.expectation), {
+ actual: actual,
+ assertMode: true
+ });
+ expectation.not = create(expectation);
+ expectation.not.assertMode = false;
+ return expectation;
+ };
+
+ expect.expectation = expectation;
+
+ expect.wrapAssertion = function (assertion, expectation, referee) {
+ expect.expectation[expectation] = function () {
+ var args = [this.actual].concat(_.toArray(arguments));
+ var type = this.assertMode ? "assert" : "refute";
+ var callFunc;
+
+ if (assertion === "assert") {
+ callFunc = this.assertMode ? referee.assert : referee.refute;
+ } else if (assertion === "refute") {
+ callFunc = this.assertMode ? referee.refute : referee.assert;
+ } else {
+ callFunc = referee[type][assertion];
+ }
+
+ try {
+ return callFunc.apply(referee.expect, args);
+ } catch (e) {
+ e.message = (e.message || "").replace(
+ "[" + type + "." + assertion + "]",
+ "[expect." + (this.assertMode ? "" : "not.") +
+ expectation + "]"
+ );
+ throw e;
+ }
+ };
+ };
+
+ expect.init = function (referee) {
+ _.each(_.keys(referee.assert), function (name) {
+ var expectationName = referee.assert[name].expectationName;
+ if (expectationName) {
+ expect.wrapAssertion(name, expectationName, referee);
+ }
+ });
+
+ expect.wrapAssertion("assert", "toBeTruthy", referee);
+ expect.wrapAssertion("refute", "toBeFalsy", referee);
+
+ if (expect.expectation.toBeNear) {
+ expect.expectation.toBeCloseTo = expect.expectation.toBeNear;
+ }
+ };
+
+ return expect;
+});
diff --git a/debian/node_modules/referee/lib/referee.js b/debian/node_modules/referee/lib/referee.js
new file mode 100644
index 0000000..b000c2e
--- /dev/null
+++ b/debian/node_modules/referee/lib/referee.js
@@ -0,0 +1,716 @@
+((typeof define === "function" && define.amd && function (m) {
+ define("referee", ["expect", "lodash", "samsam", "bane"], m);
+}) || (typeof module === "object" && function (m) {
+ module.exports = m(
+ require("./expect"),
+ require("lodash"),
+ require("samsam"),
+ require("bane")
+ );
+}) || function (m) {
+ this.referee = m(
+ this.expect,
+ this._,
+ this.samsam,
+ this.bane
+ );
+})(function (expect, _, samsam, bane) {
+ "use strict";
+
+ var toString = Object.prototype.toString;
+ var slice = Array.prototype.slice;
+ var assert, refute, referee = bane.createEventEmitter();
+
+ referee.countAssertion = function countAssertion() {
+ if (typeof referee.count !== "number") { referee.count = 0; }
+ referee.count += 1;
+ };
+
+ function interpolate(string, prop, value) {
+ return string.replace(new RegExp("\\$\\{" + prop + "\\}", "g"), value);
+ }
+
+ // Interpolate positional arguments. Replaces occurences of ${<index>} in
+ // the string with the corresponding entry in values[<index>]
+ function interpolatePosArg(message, values) {
+ return _.reduce(values, function (msg, value, index) {
+ return interpolate(msg, index, referee.format(value));
+ }, message);
+ }
+
+ function interpolateProperties(message, properties) {
+ return _.reduce(_.keys(properties), function (str, name) {
+ var formattedValue = name === "customMessage" ? referee.prepareMessage(properties[name]) : referee.format(properties[name]);
+ return interpolate(str, name, formattedValue);
+ }, message || "");
+ }
+
+ // Internal helper. Used throughout to fail assertions if they receive
+ // too few arguments. The name is provided for a helpful error message.
+ function assertArgNum(name, args, num, fail) {
+ fail = fail || referee.fail;
+ if (args.length < num) {
+ fail("[" + name + "] Expected to receive at least " +
+ num + " argument" + (num > 1 ? "s" : ""));
+ return false;
+ }
+ return true;
+ }
+
+ function createAssertion(type, name, func, minArgs, messageValues, pass, fail) {
+
+ var assertion = function () {
+
+ var fullName = type + "." + name, failed = false;
+
+ if (!assertArgNum(fullName, arguments, minArgs || func.length, fail)) {
+ return;
+ }
+
+ var args = slice.call(arguments, 0),
+ namedValues = {};
+
+ if (typeof messageValues === "function") {
+ var replacedValues = messageValues.apply(this, args);
+ if (typeof(replacedValues) === "object") {
+ namedValues = replacedValues;
+ } else {
+ args = replacedValues;
+ }
+ }
+
+ var ctx = {
+ fail: function (msg) {
+ failed = true;
+ delete this.fail;
+ var message = referee[type][name][msg] || msg;
+ message = interpolatePosArg(message, args);
+ message = interpolateProperties(message, this);
+ message = interpolateProperties(message, namedValues);
+ fail("[" + type + "." + name + "] " + message);
+ return false;
+ }
+ };
+
+ if (!func.apply(ctx, arguments) && !failed) {
+ // when a function returns false and hasn't already failed with a custom message,
+ // fail with default message
+ ctx.fail("message");
+ }
+
+ if (!failed) {
+ pass(["pass", fullName].concat(args));
+ }
+ };
+
+ return assertion;
+ }
+
+ // Internal helper. Not the most elegant of functions, but it takes
+ // care of all the nitty-gritty of assertion functions: counting,
+ // verifying parameter count, interpolating messages with actual
+ // values and so on.
+ function defineAssertion(type, name, func, minArgs, messageValues) {
+
+ referee[type][name] = function () {
+ referee.countAssertion();
+ var assertion = createAssertion(type, name, func, minArgs, messageValues, referee.pass, referee.fail);
+ assertion.apply(null, arguments);
+ };
+ referee[type][name].test = function () {
+ var args = arguments;
+ return new Promise(function (resolve, reject) {
+ var assertion = createAssertion(type, name, func, minArgs, messageValues, resolve, reject);
+ assertion.apply(null, args);
+ });
+ };
+ }
+
+ referee.add = function (name, opt) {
+ var refuteArgs;
+
+ if (opt.refute) {
+ refuteArgs = opt.refute.length;
+ } else {
+ refuteArgs = opt.assert.length;
+ opt.refute = function () {
+ return !opt.assert.apply(this, arguments);
+ };
+ }
+
+ var values = opt.values;
+ defineAssertion("assert", name, opt.assert, opt.assert.length, values);
+ defineAssertion("refute", name, opt.refute, refuteArgs, values);
+
+ assert[name].message = opt.assertMessage;
+ refute[name].message = opt.refuteMessage;
+
+ if (opt.expectation) {
+ if (referee.expect && referee.expect.wrapAssertion) {
+ referee.expect.wrapAssertion(name, opt.expectation, referee);
+ } else {
+ assert[name].expectationName = opt.expectation;
+ refute[name].expectationName = opt.expectation;
+ }
+ }
+ };
+
+ assert = referee.assert = function assert(actual, message) {
+ referee.countAssertion();
+ if (!assertArgNum("assert", arguments, 1)) { return; }
+
+ if (!actual) {
+ var v = referee.format(actual);
+ referee.fail(message || "[assert] Expected " + v + " to be truthy");
+ } else {
+ referee.emit("pass", "assert", message || "", actual);
+ }
+ };
+
+ assert.toString = function () {
+ return "referee.assert()";
+ };
+
+ refute = referee.refute = function (actual, message) {
+ referee.countAssertion();
+ if (!assertArgNum("refute", arguments, 1)) { return; }
+
+ if (actual) {
+ var v = referee.format(actual);
+ referee.fail(message || "[refute] Expected " + v + " to be falsy");
+ } else {
+ referee.emit("pass", "refute", message || "", actual);
+ }
+ };
+
+ referee.count = 0;
+
+ referee.pass = function (message) {
+ referee.emit.apply(referee, message);
+ }
+
+ referee.fail = function (message) {
+ var exception = new Error(message);
+ exception.name = "AssertionError";
+
+ try {
+ throw exception;
+ } catch (e) {
+ referee.emit("failure", e);
+ }
+
+ if (typeof referee.throwOnFailure !== "boolean" ||
+ referee.throwOnFailure) {
+ throw exception;
+ }
+ };
+
+ referee.format = function (object) { return String(object); };
+
+ referee.prepareMessage = function msg(message) {
+ if (!message) {
+ return "";
+ }
+ return message + (/[.:!?]$/.test(message) ? " " : ": ");
+ };
+
+ function actualAndExpectedMessageValues(actual, expected, message) {
+ return {
+ actual: actual,
+ expected: expected,
+ customMessage: message
+ };
+ }
+
+ function actualMessageValues(actual, message) {
+ return {
+ actual: actual,
+ customMessage: message
+ };
+ }
+
+ function actualAndTypeOfMessageValues(actual, message) {
+ return {
+ actual: actual,
+ actualType: typeof actual,
+ customMessage: message
+ };
+ }
+
+ referee.add("same", {
+ assert: function (actual, expected) {
+ return samsam.identical(actual, expected);
+ },
+ refute: function (actual, expected) {
+ return !samsam.identical(actual, expected);
+ },
+ assertMessage: "${customMessage}${actual} expected to be the same object as ${expected}",
+ refuteMessage: "${customMessage}${actual} expected not to be the same object as ${expected}",
+ expectation: "toBe",
+ values: actualAndExpectedMessageValues
+ });
+
+ // Extract/replace with separate module that does a more detailed
+ // visualization of multi-line strings
+ function multiLineStringDiff(actual, expected, message) {
+ if (actual === expected) { return true; }
+
+ var heading = assert.equals.multiLineStringHeading;
+ var failureText = interpolateProperties(heading, { customMessage: message });
+ var actualLines = actual.split("\n");
+ var expectedLines = expected.split("\n");
+ var lineCount = Math.max(expectedLines.length, actualLines.length);
+ var i, lines = [];
+
+ for (i = 0; i < lineCount; ++i) {
+ if (expectedLines[i] !== actualLines[i]) {
+ lines.push("line " + (i + 1) + ": " + (expectedLines[i] || "") +
+ "\nwas: " + (actualLines[i] || ""));
+ }
+ }
+
+ referee.fail("[assert.equals] " + failureText + lines.join("\n\n"));
+ return false;
+ }
+
+ referee.add("equals", {
+ // Uses arguments[2] because the function's .length is used to determine
+ // the minimum required number of arguments.
+ assert: function (actual, expected) {
+ if (typeof actual === "string" && typeof expected === "string" &&
+ (actual.indexOf("\n") >= 0 ||
+ expected.indexOf("\n") >= 0)) {
+ return multiLineStringDiff(actual, expected, arguments[2]);
+ }
+
+ return samsam.deepEqual(actual, expected);
+ },
+
+ refute: function (actual, expected) {
+ return !samsam.deepEqual(actual, expected);
+ },
+
+ assertMessage: "${customMessage}${actual} expected to be equal to ${expected}",
+ refuteMessage: "${customMessage}${actual} expected not to be equal to ${expected}",
+ expectation: "toEqual",
+ values: actualAndExpectedMessageValues
+ });
+
+ assert.equals.multiLineStringHeading = "${customMessage}Expected multi-line strings " +
+ "to be equal:\n";
+
+ referee.add("greater", {
+ assert: function (actual, expected) {
+ return actual > expected;
+ },
+
+ assertMessage: "${customMessage}Expected ${actual} to be greater than ${expected}",
+ refuteMessage: "${customMessage}Expected ${actual} to be less than or equal to ${expected}",
+ expectation: "toBeGreaterThan",
+ values: actualAndExpectedMessageValues
+ });
+
+ referee.add("less", {
+ assert: function (actual, expected) {
+ return actual < expected;
+ },
+
+ assertMessage: "${customMessage}Expected ${actual} to be less than ${expected}",
+ refuteMessage: "${customMessage}Expected ${actual} to be greater than or equal to ${expected}",
+ expectation: "toBeLessThan",
+ values: actualAndExpectedMessageValues
+ });
+
+ referee.add("defined", {
+ assert: function (actual) {
+ return typeof actual !== "undefined";
+ },
+ assertMessage: "${customMessage}Expected to be defined",
+ refuteMessage: "${customMessage}Expected ${actual} (${actualType}) not to be defined",
+ expectation: "toBeDefined",
+ values: actualAndTypeOfMessageValues
+ });
+
+ referee.add("isNull", {
+ assert: function (actual) {
+ return actual === null;
+ },
+ assertMessage: "${customMessage}Expected ${actual} to be null",
+ refuteMessage: "${customMessage}Expected not to be null",
+ expectation: "toBeNull",
+ values: actualMessageValues
+ });
+
+
+ referee.match = function (actual, matcher) {
+ try {
+ return samsam.match(actual, matcher);
+ } catch (e) {
+ throw new Error("Matcher (" + referee.format(matcher) +
+ ") was not a string, a number, a function, " +
+ "a boolean or an object");
+ }
+ };
+
+ referee.add("match", {
+ assert: function (actual, matcher) {
+ var passed;
+
+ try {
+ passed = referee.match(actual, matcher);
+ } catch (e) {
+ this.exceptionMessage = e.message;
+ return this.fail("exceptionMessage");
+ }
+
+ return passed;
+ },
+
+ refute: function (actual, matcher) {
+ var passed;
+
+ try {
+ passed = referee.match(actual, matcher);
+ } catch (e) {
+ this.exceptionMessage = e.message;
+ return this.fail("exceptionMessage");
+ }
+
+ return !passed;
+ },
+
+ assertMessage: "${customMessage}${actual} expected to match ${expected}",
+ refuteMessage: "${customMessage}${actual} expected not to match ${expected}",
+ expectation: "toMatch",
+ values: actualAndExpectedMessageValues
+ });
+
+ assert.match.exceptionMessage = refute.match.exceptionMessage = "${customMessage}${exceptionMessage}";
+
+ referee.add("isObject", {
+ assert: function (actual) {
+ return typeof actual === "object" && !!actual;
+ },
+ assertMessage: "${customMessage}${actual} (${actualType}) expected to be object and not null",
+ refuteMessage: "${customMessage}${actual} expected to be null or not an object",
+ expectation: "toBeObject",
+ values: actualAndTypeOfMessageValues
+ });
+
+ referee.add("isFunction", {
+ assert: function (actual) {
+ return typeof actual === "function";
+ },
+ assertMessage: "${customMessage}${actual} (${actualType}) expected to be function",
+ refuteMessage: "${customMessage}${actual} expected not to be function",
+ expectation: "toBeFunction",
+ values: function (actual, message) {
+ return {
+ actual: String(actual).replace("\n", ""),
+ actualType: typeof actual,
+ customMessage: message
+ };
+ }
+ });
+
+ referee.add("isTrue", {
+ assert: function (actual) {
+ return actual === true;
+ },
+ assertMessage: "${customMessage}Expected ${actual} to be true",
+ refuteMessage: "${customMessage}Expected ${actual} to not be true",
+ expectation: "toBeTrue",
+ values: actualMessageValues
+ });
+
+ referee.add("isFalse", {
+ assert: function (actual) {
+ return actual === false;
+ },
+ assertMessage: "${customMessage}Expected ${actual} to be false",
+ refuteMessage: "${customMessage}Expected ${actual} to not be false",
+ expectation: "toBeFalse",
+ values: actualMessageValues
+ });
+
+ referee.add("isString", {
+ assert: function (actual) {
+ return typeof actual === "string";
+ },
+ assertMessage: "${customMessage}Expected ${actual} (${actualType}) to be string",
+ refuteMessage: "${customMessage}Expected ${actual} not to be string",
+ expectation: "toBeString",
+ values: actualAndTypeOfMessageValues
+ });
+
+ referee.add("isBoolean", {
+ assert: function (actual) {
+ return typeof actual === "boolean";
+ },
+ assertMessage: "${customMessage}Expected ${actual} (${actualType}) to be boolean",
+ refuteMessage: "${customMessage}Expected ${actual} not to be boolean",
+ expectation: "toBeBoolean",
+ values: actualAndTypeOfMessageValues
+ });
+
+ referee.add("isNumber", {
+ assert: function (actual) {
+ return typeof actual === "number" && !isNaN(actual);
+ },
+ assertMessage: "${customMessage}Expected ${actual} (${actualType}) to be a non-NaN number",
+ refuteMessage: "${customMessage}Expected ${actual} to be NaN or a non-number value",
+ expectation: "toBeNumber",
+ values: actualAndTypeOfMessageValues
+ });
+
+ referee.add("isNaN", {
+ assert: function (actual) {
+ return typeof actual === "number" && isNaN(actual);
+ },
+ assertMessage: "${customMessage}Expected ${actual} to be NaN",
+ refuteMessage: "${customMessage}Expected not to be NaN",
+ expectation: "toBeNaN",
+ values: actualAndTypeOfMessageValues
+ });
+
+ referee.add("isArray", {
+ assert: function (actual) {
+ return toString.call(actual) === "[object Array]";
+ },
+ assertMessage: "${customMessage}Expected ${actual} to be array",
+ refuteMessage: "${customMessage}Expected ${actual} not to be array",
+ expectation: "toBeArray",
+ values: actualAndTypeOfMessageValues
+ });
+
+ function isArrayLike(object) {
+ return _.isArray(object) ||
+ (!!object && typeof object.length === "number" &&
+ typeof object.splice === "function") ||
+ _.isArguments(object);
+ }
+
+ referee.isArrayLike = isArrayLike;
+
+ referee.add("isArrayLike", {
+ assert: function (actual) {
+ return isArrayLike(actual);
+ },
+ assertMessage: "${customMessage}Expected ${actual} to be array like",
+ refuteMessage: "${customMessage}Expected ${actual} not to be array like",
+ expectation: "toBeArrayLike",
+ values: actualAndTypeOfMessageValues
+ });
+
+ function exactKeys(object, keys) {
+ var keyMap = {};
+ var keyCnt = 0;
+ for (var i = 0; i < keys.length; i++) {
+ keyMap[keys[i]] = true;
+ keyCnt += 1;
+ }
+ for (var key in object) {
+ if (object.hasOwnProperty(key)) {
+ if (! keyMap[key]) {
+ return false;
+ }
+ keyCnt -= 1;
+ }
+ }
+ return keyCnt === 0;
+ }
+
+ referee.add("keys", {
+ assert: function (actual, keys) {
+ return exactKeys(actual, keys);
+ },
+ assertMessage: "${customMessage}Expected ${actualObject} to have exact keys ${keys}",
+ refuteMessage: "${customMessage}Expected not to have exact keys ${keys}",
+ expectation: "toHaveKeys",
+ values: function (actual, keys, message) {
+ return {
+ actualObject: actual,
+ keys: keys,
+ customMessage: message
+ }
+ }
+ });
+
+ function captureException(callback) {
+ try { callback(); } catch (e) { return e; }
+ return null;
+ }
+
+ referee.captureException = captureException;
+
+ referee.add("exception", {
+ assert: function (callback) {
+ var matcher = arguments[1];
+ var customMessage = arguments[2];
+
+ if (typeof matcher === "string") {
+ customMessage = matcher;
+ matcher = undefined;
+ }
+
+ this.expected = matcher;
+ this.customMessage = customMessage;
+
+ var err = captureException(callback);
+
+ if (err) {
+ this.actualExceptionType = err.name;
+ this.actualExceptionMessage = err.message;
+ this.actualExceptionStack = err.stack;
+ }
+
+ if (!err) {
+ if (typeof matcher === "object") {
+ return this.fail("typeNoExceptionMessage");
+ } else {
+ return this.fail("message");
+ }
+ }
+
+ if (typeof matcher === "object" && !referee.match(err, matcher)) {
+ return this.fail("typeFailMessage");
+ }
+
+ if (typeof matcher === "function" && matcher(err) !== true) {
+ return this.fail("matchFailMessage");
+ }
+
+ return true;
+ },
+
+ refute: function (callback) {
+ var err = captureException(callback);
+
+ if (err) {
+ this.customMessage = arguments[1];
+ this.actualExceptionType = err.name;
+ this.actualExceptionMessage = err.message;
+ return false;
+ }
+
+ return true;
+ },
+
+ expectation: "toThrow",
+ assertMessage: "${customMessage}Expected exception",
+ refuteMessage: "${customMessage}Expected not to throw but threw ${actualExceptionType} (${actualExceptionMessage})"
+ });
+
+ assert.exception.typeNoExceptionMessage = "${customMessage}Expected ${expected} but no exception was thrown";
+ assert.exception.typeFailMessage = "${customMessage}Expected ${expected} but threw ${actualExceptionType} (${actualExceptionMessage})\n${actualExceptionStack}";
+ assert.exception.matchFailMessage = "${customMessage}Expected thrown ${actualExceptionType} (${actualExceptionMessage}) to pass matcher function";
+
+
+ referee.add("near", {
+ assert: function (actual, expected, delta) {
+ return Math.abs(actual - expected) <= delta;
+ },
+ assertMessage: "${customMessage}Expected ${actual} to be equal to ${expected} +/- ${delta}",
+ refuteMessage: "${customMessage}Expected ${actual} not to be equal to ${expected} +/- ${delta}",
+ expectation: "toBeNear",
+ values: function (actual, expected, delta, message) {
+ return {
+ actual: actual,
+ expected: expected,
+ delta: delta,
+ customMessage: message
+ };
+ }
+ });
+
+ referee.add("hasPrototype", {
+ assert: function (actual, protoObj) {
+ return protoObj.isPrototypeOf(actual);
+ },
+ assertMessage: "${customMessage}Expected ${actual} to have ${expected} on its prototype chain",
+ refuteMessage: "${customMessage}Expected ${actual} not to have ${expected} on its " +
+ "prototype chain",
+ expectation: "toHavePrototype",
+ values: actualAndExpectedMessageValues
+ });
+
+ referee.add("contains", {
+ assert: function (haystack, needle) {
+ return _.include(haystack, needle);
+ },
+ assertMessage: "${customMessage}Expected [${actual}] to contain ${expected}",
+ refuteMessage: "${customMessage}Expected [${actual}] not to contain ${expected}",
+ expectation: "toContain",
+ values: actualAndExpectedMessageValues
+ });
+
+ referee.add("tagName", {
+ assert: function (element, tagName) {
+ // Uses arguments[2] because the function's .length is used to
+ // determine the minimum required number of arguments.
+ if (!element.tagName) {
+ return this.fail("noTagNameMessage");
+ }
+
+ return tagName.toLowerCase &&
+ tagName.toLowerCase() === element.tagName.toLowerCase();
+ },
+ assertMessage: "${customMessage}Expected tagName to be ${expected} but was ${actual}",
+ refuteMessage: "${customMessage}Expected tagName not to be ${actual}",
+ expectation: "toHaveTagName",
+ values: function (element, tagName, message) {
+ return {
+ actualElement: element,
+ actual: element.tagName,
+ expected: tagName,
+ customMessage: message
+ };
+ }
+ });
+
+ assert.tagName.noTagNameMessage = "${customMessage}Expected ${actualElement} to have tagName " +
+ "property";
+ refute.tagName.noTagNameMessage = "${customMessage}Expected ${actualElement} to have tagName " +
+ "property";
+
+ referee.add("className", {
+ assert: function (element, name) {
+ if (typeof element.className === "undefined") {
+ return this.fail("noClassNameMessage");
+ }
+
+ var expected = typeof name === "string" ? name.split(" ") : name;
+ var actual = element.className.split(" ");
+ var i, l;
+ for (i = 0, l = expected.length; i < l; i++) {
+ if (!_.include(actual, expected[i])) { return false; }
+ }
+
+ return true;
+ },
+ assertMessage: "${customMessage}Expected object's className to include ${expected} " +
+ "but was ${actual}",
+ refuteMessage: "${customMessage}Expected object's className not to include ${expected}",
+ expectation: "toHaveClassName",
+ values: function (element, className, message) {
+ return {
+ actualElement: element,
+ actual: element.className,
+ expected: className,
+ customMessage: message
+ };
+ }
+ });
+
+ assert.className.noClassNameMessage = "${customMessage}Expected object to have " +
+ "className property";
+ refute.className.noClassNameMessage = "${customMessage}Expected object to have " +
+ "className property";
+
+ referee.expect = function () {
+ expect.init(referee);
+ return expect.apply(referee, arguments);
+ };
+
+ return referee;
+});
\ No newline at end of file
diff --git a/debian/node_modules/referee/package.json b/debian/node_modules/referee/package.json
new file mode 100644
index 0000000..211f90d
--- /dev/null
+++ b/debian/node_modules/referee/package.json
@@ -0,0 +1,54 @@
+{
+ "name": "referee",
+ "version": "1.2.0",
+ "description": "Assertions for any JavaScript test framework and environment",
+ "homepage": "http://docs.busterjs.org/en/latest/modules/referee/",
+ "author": "Christian Johansen",
+ "contributors": [
+ {
+ "name": "Christian Johansen",
+ "email": "christian at cjohansen.no",
+ "url": "http://cjohansen.no"
+ },
+ {
+ "name": "August Lilleaas",
+ "email": "august.lilleaas at gmail.com",
+ "url": "http://augustl.com"
+ },
+ {
+ "name": "Dave Geddes",
+ "email": "davidcgeddes at gmail.com"
+ },
+ {
+ "name": "Malcolm Locke",
+ "email": "malc at wholemeal.co.nz"
+ },
+ {
+ "name": "Stein Magnus Jodal",
+ "email": "stein.magnus at jodal.no"
+ }
+ ],
+ "license": "BSD-3-Clause",
+ "main": "./lib/referee",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/busterjs/referee"
+ },
+ "scripts": {
+ "test": "grunt test"
+ },
+ "dependencies": {
+ "lodash": "3.x",
+ "samsam": "1.x",
+ "bane": "1.x"
+ },
+ "devDependencies": {
+ "grunt": "0.4.x",
+ "grunt-buster": "0.4.x",
+ "grunt-cli": "0.1.x",
+ "buster": "0.7.x",
+ "phantomjs": "1.9.x",
+ "sinon": "1.x",
+ "when": "3.x"
+ }
+}
diff --git a/debian/node_modules/referee/test/expect-test.js b/debian/node_modules/referee/test/expect-test.js
new file mode 100644
index 0000000..8bf1b56
--- /dev/null
+++ b/debian/node_modules/referee/test/expect-test.js
@@ -0,0 +1,115 @@
+/*jslint maxlen:160*/
+(function (referee, testHelper, buster, sinon) {
+ 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 assert = buster.referee.assert;
+ var refute = buster.referee.refute;
+
+ buster.testCase("expect", {
+ setUp: testHelper.setUp,
+ tearDown: testHelper.tearDown,
+
+ "should be function": function () {
+ assert.equals(typeof expect, "function");
+ },
+
+ "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.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) {}
+
+ assert(referee.fail.calledOnce);
+ },
+
+ "should emit assertion pass event": function () {
+ var listener = sinon.spy();
+ referee.on("pass", listener);
+
+ expect({ id: 42 }).toEqual({ id: 42 });
+
+ assert(listener.calledOnce);
+ },
+
+ "should emit assertion fail event": function () {
+ var listener = sinon.spy();
+ referee.on("failure", listener);
+ referee.throwOnFailure = false;
+
+ expect({ id: 42 }).toEqual({ id: 22 });
+
+ 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.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 };
+
+ 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));
diff --git a/debian/node_modules/referee/test/referee-test.js b/debian/node_modules/referee/test/referee-test.js
new file mode 100644
index 0000000..5524784
--- /dev/null
+++ b/debian/node_modules/referee/test/referee-test.js
@@ -0,0 +1,1725 @@
+(function (referee, testHelper, buster) {
+ if (typeof require === "function" && typeof module === "object") {
+ referee = require("../lib/referee");
+ testHelper = require("./test-helper");
+ buster = require("buster");
+ }
+
+ var assert = buster.referee.assert;
+ var refute = buster.referee.refute;
+
+ buster.testCase("assert", {
+ setUp: testHelper.setUp,
+ tearDown: testHelper.tearDown,
+
+ "allows true": function () {
+ var okListener = this.spy();
+ referee.on("pass", okListener);
+
+ refute.exception(function () {
+ referee.assert(true);
+ });
+
+ assert.calledOnce(okListener);
+ assert.calledWith(okListener, "assert");
+ },
+
+ "allows truthy values": function () {
+ refute.exception(function () {
+ referee.assert({});
+ referee.assert([]);
+ referee.assert("Truthy");
+ referee.assert(1);
+ referee.assert(/a/);
+ });
+ },
+
+ "allows true with message": function () {
+ refute.exception(function () {
+ referee.assert(true, "s'aright");
+ });
+ },
+
+ "does not allow false": function () {
+ var okListener = this.spy();
+ referee.on("pass", okListener);
+
+ assert.exception(function () {
+ referee.assert(false);
+ });
+
+ refute.called(okListener);
+ },
+
+ "does not allow falsy values": function () {
+ assert.exception(function () {
+ referee.assert("");
+ });
+
+ assert.exception(function () {
+ referee.assert(0);
+ });
+
+ assert.exception(function () {
+ referee.assert(NaN);
+ });
+
+ assert.exception(function () {
+ referee.assert(null);
+ });
+
+ assert.exception(function () {
+ referee.assert(undefined);
+ });
+ },
+
+ "does not allow false with message": function () {
+ assert.exception(function () {
+ referee.assert(false, "Some message");
+ });
+ },
+
+ "fails with generated message": function () {
+ try {
+ referee.assert(false);
+ throw new Error("Didn't fail");
+ } catch (e) {
+ assert.equals(e.name, "AssertionError");
+ assert.equals(e.message, "[assert] Expected false to be truthy");
+ }
+ },
+
+ "fails with custom message": function () {
+ try {
+ referee.assert(false, "False FTW");
+ throw new Error("Didn't fail");
+ } catch (e) {
+ assert.equals(e.name, "AssertionError");
+ assert.equals(e.message, "False FTW");
+ }
+ },
+
+ "updates assertion count": function () {
+ referee.count = 0;
+
+ try {
+ referee.assert(true);
+ referee.assert(false);
+ } catch (e) {}
+
+ assert.equals(referee.count, 2);
+ },
+
+ "formats value with assert.format": function () {
+ referee.format = this.spy();
+
+ try {
+ referee.assert(false);
+ } catch (e) {}
+
+ assert.calledOnce(referee.format);
+ assert.calledWith(referee.format, false);
+ },
+
+ "fails if not passed arguments": function () {
+ try {
+ referee.assert();
+ throw new Error("Expected assert to fail");
+ } catch (e) {
+ assert.equals(e.message, "[assert] Expected to receive at least 1 argument");
+ }
+ },
+
+ "does not throw if not configured to":
+ testHelper.assertionFailureEventTest(function () {
+ referee.assert(false);
+ })
+ });
+
+ buster.testCase("plain asserts", {
+ "assertions expose plain asserts via method test": function () {
+ assert.isFunction(referee.assert.equals.test);
+ },
+ "test returns promise": function () {
+ assert.isFunction(referee.assert.equals.test("", "").then);
+ },
+ "failed resolves to error": function () {
+ return referee.assert.equals.test("actual", "expected").then(undefined, function (message) {
+ assert.defined(message);
+ });
+ },
+ "proper default failure message": function () {
+ return referee.assert.equals.test("actual", "expected").then(undefined, function (message) {
+ assert.equals(message, "[assert.equals] actual expected to be equal to expected");
+ });
+ },
+ "proper custom failure message without args": function () {
+ return referee.assert.equals.test("actual",
+ "expected",
+ "custom message").then(undefined, function (message) {
+ assert.equals(message, "[assert.equals] custom message: actual expected to be equal to expected");
+ });
+ },
+ "successful resolves success": function () {
+ return referee.assert.equals.test("expected", "expected").then(function (message) {
+ assert.equals(message, ["pass", "assert.equals", "expected", "expected"]);
+ });
+ },
+ "this.fail works from assertions": function () {
+ return referee.assert.className.test({}, "Item").then(undefined, function (message) {
+ assert.equals(message,
+ "[assert.className] Expected object to have className property");
+ });
+ }
+
+ });
+
+ function plainAssertionTests(assertion, type, name, declareTests) {
+ function withExpected(expected, tests) {
+ return tests({
+ pass: function (actual) {
+ return function () {
+ return Promise.resolve(assertion.apply(this, [actual].concat(expected))).then(buster.assert.defined, buster.refute.defined);
+ }
+ },
+ fail: function (actual) {
+ return function () {
+ return Promise.resolve(assertion.apply(this, [actual].concat(expected))).then(buster.refute.defined, buster.assert.defined);
+ }
+ },
+ yieldMsg: function (expectedMessage, actual) {
+ return function () {
+ return Promise.resolve(assertion.apply(this, [actual].concat(expected))).then(buster.refute.defined, function (actualMessage) {
+ buster.assert.equals(actualMessage, "[" + type + "." + name + "] " + expectedMessage)
+ });
+ }
+ }
+ });
+ }
+
+ var declared = declareTests(withExpected);
+ buster.testCase(type + "." + name + ".test", declared);
+ }
+
+ plainAssertionTests(referee.assert.equals.test, "assert", "equals", function (given) {
+ return {
+ "expected string -" : given(["the string"], function (must) {
+ return {
+ "pass for equal": must.pass("the string"),
+ "fail for different": must.fail("different"),
+ "message is ok": must.yieldMsg("other expected to be equal to the string", "other")
+ }
+ })
+ };
+ });
+
+ plainAssertionTests(referee.assert.className.test, "assert", "className", function (given) {
+ return {
+ "classname -": given(["item"], function (must) {
+ return {
+ "fail when element does not include class name" : must.yieldMsg(
+ "Expected object's className to include item but was ", {className: ""})
+ }
+ })
+ }
+ });
+
+ plainAssertionTests(referee.refute.tagName.test, "refute", "tagName", function (given) {
+ return {
+ "tagname -": given(["li", "Yes"], function (must) {
+ return {
+ "fail with custom message if object does not have tagName property" : must.yieldMsg(
+ "Yes: Expected [object Object] to have tagName property", {})
+ }
+ })
+ }
+ });
+
+ testHelper.assertionTests("assert", "isTrue", function (pass, fail, msg) {
+ pass("for true", true);
+ fail("for false", false);
+ msg("represent expected value in message",
+ "[assert.isTrue] Expected [object Object] to be true", {});
+ msg("include custom message",
+ "[assert.isTrue] Oh: Expected [object Object] to be true",
+ {},
+ "Oh");
+ fail("for object", {});
+ fail("for array", []);
+ fail("for string", "32");
+ fail("for number", 32);
+ msg("fail if not passed arguments",
+ "[assert.isTrue] Expected to receive at least 1 argument");
+ });
+
+ testHelper.assertionTests("assert", "isFalse", function (pass, fail, msg, callbacks) {
+ pass("for false", false);
+ fail("for true", true);
+ msg("fail with message",
+ "[assert.isFalse] Expected true to be false", true);
+ msg("fail with custom message",
+ "[assert.isFalse] Nooo! Expected true to be false", true, "Nooo!");
+ msg("represent expected value in message",
+ "[assert.isFalse] Expected [object Object] to be false", {});
+ fail("for empty string", "");
+ fail("for 0", 0);
+ fail("for NaN", NaN);
+ fail("for null", null);
+ fail("for undefined", undefined);
+ });
+
+ var obj = { id: 42 };
+ var obj2 = { id: 42 };
+
+ testHelper.assertionTests("assert", "same", function (pass, fail, msg) {
+ pass("when comparing object to itself", obj, obj);
+ fail("when comparing different objects", obj, obj2);
+ pass("when comparing strings", "Hey", "Hey");
+ pass("when comparing booleans", true, true);
+ pass("when comparing numbers", 32, 32);
+ pass("when comparing infinity", Infinity, Infinity);
+ fail("when comparing without coercion", 666, "666");
+ fail("when comparing falsy values without coercion", 0, "");
+ pass("when comparing null to null", null, null);
+ pass("when comparing undefined to undefined", undefined, undefined);
+ msg("include objects in message",
+ "[assert.same] Obj expected to be the same object as [object Object]",
+ "Obj", {});
+ msg("include custom message",
+ "[assert.same] Back again: Obj expected to be the same object as [object Object]",
+ "Obj", {}, "Back again");
+ pass("when comparing NaN to NaN", NaN, NaN);
+ fail("when comparing -0 to +0", -0, +0);
+ });
+
+ testHelper.assertionTests("refute", "same", function (pass, fail, msg) {
+ fail("comparing object to itself", obj, obj);
+ pass("when comparing different objects", obj, obj2);
+ fail("when comparing strings", "Hey", "Hey");
+ fail("when comparing booleans", true, true);
+ fail("when comparing numbers", 32, 32);
+ fail("when comparing infinity", Infinity, Infinity);
+ fail("when comparing null to null", null, null);
+ fail("when comparing undefined to undefined", undefined, undefined);
+ msg("include objects in message",
+ "[refute.same] [object Object] expected not to be the same object as [object Object]", obj, obj);
+ msg("include custom message",
+ "[refute.same] Sigh... [object Object] expected not to be the same object as [object Object]",
+ obj, obj, "Sigh...");
+ fail("when comparing NaN to NaN", NaN, NaN);
+ pass("when comparing -0 to +0", -0, +0);
+ });
+
+ testHelper.assertionTests("assert", "equals", function (pass, fail, msg) {
+ var func = function () {};
+ var arr = [];
+ var date = new Date();
+ var sameDate = new Date(date.getTime());
+ var anotherDate = new Date(date.getTime() - 10);
+
+ pass("when comparing object to itself", obj, obj);
+ pass("when comparing strings", "Hey", "Hey");
+ pass("when comparing numbers", 32, 32);
+ pass("when comparing booleans", false, false);
+ pass("when comparing null", null, null);
+ pass("when comparing undefined", undefined, undefined);
+ pass("when comparing function to itself", func, func);
+ fail("when comparing functions", function () {}, function () {});
+ pass("when comparing array to itself", arr, arr);
+ pass("when comparing date objects with same date", date, sameDate);
+ fail("when comparing date objects with different dates", date, anotherDate);
+ fail("when comparing date objects to null", date, null);
+ fail("when comparing strings and numbers with coercion", "4", 4);
+ fail("when comparing numbers and strings with coercion", 4, "4");
+ fail("when comparing number object with coercion", 32, new Number(32));
+ fail("when comparing number object reverse with coercion", new Number(32), 32);
+ fail("when comparing falsy values with coercion", 0, "");
+ fail("when comparing falsy values reverse with coercion", "", 0);
+ fail("when comparing string boxing with coercion", "4", new String("4"));
+ fail("when comparing string boxing reverse with coercion", new String("4"), "4");
+ pass("when comparing NaN to NaN", NaN, NaN);
+ fail("when comparing -0 to +0", -0, +0);
+ fail("when comparing objects with different own properties",
+ { id: 42 }, { id: 42, di: 24 });
+ fail("when comparing objects with different own properties #2",
+ { id: undefined }, { di: 24 });
+ fail("when comparing objects with different own properties #3",
+ { id: 24 }, { di: undefined });
+ pass("when comparing objects with one property", { id: 42 }, { id: 42 });
+ pass("when comparing objects with one object property",
+ { obj: { id: 42 } }, { obj: { id: 42 } });
+ fail("when comparing objects with one property with different values",
+ { id: 42 }, { id: 24 });
+
+ var deepObject = {
+ id: 42,
+ name: "Hey",
+ sayIt: function () {
+ return this.name;
+ },
+
+ child: {
+ speaking: function () {}
+ }
+ };
+
+ pass("when comparing complex objects", deepObject, {
+ sayIt: deepObject.sayIt,
+ child: { speaking: deepObject.child.speaking },
+ id: 42,
+ name: "Hey"
+ });
+
+ pass("when comparing arrays",
+ [1, 2, "Hey there", func, { id: 42, prop: [2, 3] }],
+ [1, 2, "Hey there", func, { id: 42, prop: [2, 3] }]);
+
+ pass("when comparing regexp literals", /a/, /a/);
+ pass("when comparing regexp objects", new RegExp("[a-z]+"), new RegExp("[a-z]+"));
+
+ var re1 = new RegExp("[a-z]+");
+ var re2 = new RegExp("[a-z]+");
+ re2.id = 42;
+
+ fail("when comparing nested array with shallow array", [["hey"]], ["hey"]);
+ fail("when comparing regexp objects with custom properties", re1, re2);
+ fail("when comparing different objects", { id: 42 }, {});
+ fail("when comparing object to null", {}, null);
+ fail("when comparing object to undefined", {}, undefined);
+ fail("when comparing object to false", {}, false);
+ fail("when comparing false to object", false, {});
+ fail("when comparing object to true", {}, true);
+ fail("when comparing true to object", true, {});
+ fail("when comparing 'empty' object to date", {}, new Date());
+ fail("when comparing 'empty' object to string object", {}, new String());
+ fail("when comparing 'empty' object to number object", {}, new Number());
+ fail("when comparing 'empty' object to empty array", {}, []);
+
+ function gather() { return arguments; }
+ var arrayLike = { length: 4, "0": 1, "1": 2, "2": {}, "3": [] };
+
+ pass("when comparing arguments to array", [1, 2, {}, []], gather(1, 2, {}, []));
+ pass("when comparing array to arguments", gather(), []);
+
+ pass("when comparing arguments to array like object",
+ arrayLike, gather(1, 2, {}, []));
+
+ msg("fail with understandable message",
+ "[assert.equals] [object Object] expected to be equal to Hey", {}, "Hey");
+
+ msg("fail with custom message",
+ "[assert.equals] Here: [object Object] expected to be equal to Hey",
+ {}, "Hey", "Here:");
+
+ msg("fail with special message for multi-line strings",
+ "[assert.equals] Expected multi-line strings to be equal:\n" +
+ "line 2: The quick brown fox jumps over the lazy god\n" +
+ "was: The quick brown fox jumps over the lazy dog",
+ "Yo!\nThe quick brown fox jumps over the lazy dog",
+ "Yo!\nThe quick brown fox jumps over the lazy god").expectedFormats = 0;
+
+ msg("fail with custom message for multi-line strings",
+ "[assert.equals] Slick! Expected multi-line strings to be equal:\n" +
+ "line 2: The quick brown fox jumps over the lazy god\n" +
+ "was: The quick brown fox jumps over the lazy dog",
+ "Yo!\nThe quick brown fox jumps over the lazy dog",
+ "Yo!\nThe quick brown fox jumps over the lazy god",
+ "Slick!").expectedFormats = 0;
+
+ msg("fail with special message for multi-line strings with too short actual",
+ "[assert.equals] Expected multi-line strings to be equal:\n" +
+ "line 2: The quick brown fox jumps over the lazy god\n" +
+ "was: ",
+ "Yo!",
+ "Yo!\nThe quick brown fox jumps over the lazy god").expectedFormats = 0;
+
+ msg("fail with special message for multi-line strings with too long actual",
+ "[assert.equals] Expected multi-line strings to be equal:\n" +
+ "line 2: \n" +
+ "was: The quick brown fox jumps over the lazy god",
+ "Yo!\nThe quick brown fox jumps over the lazy god",
+ "Yo!").expectedFormats = 0;
+
+ msg("fail with all differing lines in multi-line string fail",
+ "[assert.equals] Expected multi-line strings to be equal:\n" +
+ "line 1: Yo!\n" +
+ "was: Yo\n\n" +
+ "line 4: Hey\n" +
+ "was: Oh noes",
+ "Yo\n2\n3\nOh noes",
+ "Yo!\n2\n3\nHey").expectedFormats = 0;
+
+ msg("fail with regular message for one-line strings",
+ "[assert.equals] Yo expected to be equal to Hey",
+ "Yo", "Hey");
+ });
+
+ buster.testCase("assert.equals host objects", {
+ requiresSupportFor: { "DOM": typeof document !== "undefined" },
+ setUp: testHelper.setUp,
+ tearDown: testHelper.tearDown,
+
+ "should pass when comparing DOM element to itself": function () {
+ var element = document.createElement("div");
+
+ refute.exception(function () {
+ referee.assert.equals(element, element);
+ });
+ },
+
+ "should fail when comparing different DOM elements": function () {
+ var div = document.createElement("div");
+ var span = document.createElement("span");
+
+ assert.exception(function () {
+ referee.assert.equals(div, span);
+ });
+ }
+ });
+
+ testHelper.assertionTests("refute", "equals", function (pass, fail, msg) {
+ fail("when comparing object to itself", obj, obj);
+ fail("when comparing strings", "Hey", "Hey");
+ fail("when comparing numbers", 32, 32);
+ fail("when comparing booleans", false, false);
+ fail("when comparing null", null, null);
+ fail("when comparing undefined", undefined, undefined);
+
+ var func = function () {};
+ var arr = [];
+ var date = new Date();
+ var sameDate = new Date(date.getTime());
+ var anotherDate = new Date(date.getTime() - 10);
+
+ fail("when comparing function to itself", func, func);
+ pass("when comparing functions", function () {}, function () {});
+ fail("when comparing array to itself", arr, arr);
+ fail("when comparing date objects with same date", date, sameDate);
+ pass("when comparing date objects with different dates", date, anotherDate);
+ pass("when comparing date objects to null", new Date(), null);
+ pass("when comparing string with number with coercion", "4", 4);
+ pass("when comparing number with string with coercion", 32, "32");
+ pass("when comparing with coercion", 0, "");
+ pass("when comparing objects with different own properties",
+ { id: 42 }, { id: 42, di: 24 });
+ pass("when comparing objects with different own properties #2",
+ { id: undefined }, { di: 24 });
+ pass("when comparing objects with different own properties #3",
+ { id: 24 }, { di: undefined });
+ fail("when comparing objects with one property", { id: 42 }, { id: 42 });
+ fail("when comparing objects with one object property",
+ { obj: { id: 42 } }, { obj: { id: 42 } });
+ pass("when comparing objects with one property with different values",
+ { id: 42 }, { id: 24 });
+ fail("when comparing NaN to NaN", NaN, NaN);
+ pass("when comparing -0 to +0", -0, +0);
+
+ var deepObject = {
+ id: 42,
+ name: "Hey",
+ sayIt: function () {
+ return this.name;
+ },
+
+ child: {
+ speaking: function () {}
+ }
+ };
+
+ fail("when comparing complex objects", deepObject, {
+ sayIt: deepObject.sayIt,
+ child: { speaking: deepObject.child.speaking },
+ id: 42,
+ name: "Hey"
+ });
+
+ var arr1 = [1, 2, "Hey there", func, { id: 42, prop: [2, 3] }];
+ var arr2 = [1, 2, "Hey there", func, { id: 42, prop: [2, 3] }];
+
+ fail("when comparing arrays", arr1, arr2);
+ fail("when comparing regexp literals", /a/, /a/);
+
+ fail("when comparing regexp objects", new RegExp("[a-z]+"), new RegExp("[a-z]+"));
+
+ var re1 = new RegExp("[a-z]+");
+ var re2 = new RegExp("[a-z]+");
+ re2.id = 42;
+
+ pass("when comparing regexp objects with custom properties", re1, re2);
+ pass("when comparing different objects", obj, {});
+ pass("when comparing object to null", {}, null);
+ pass("when comparing null to object", {}, null);
+ pass("when comparing object to undefined", {}, undefined);
+ pass("when comparing undefined to object", undefined, {});
+ pass("when comparing object to false", {}, false);
+ pass("when comparing false to object", false, {});
+ pass("when comparing object to true", {}, true);
+ pass("when comparing true to object", true, {});
+ pass("when comparing 'empty' object to date", {}, new Date());
+ pass("when comparing 'empty' object to string object", {}, new String());
+ pass("when comparing 'empty' object to number object", {}, new Number());
+ pass("when comparing 'empty' object to empty array", {}, []);
+ pass("when comparing multi-line strings", "Hey\nHo", "Yo\nNo");
+
+ function gather() { return arguments; }
+ var arrayLike = { length: 4, "0": 1, "1": 2, "2": {}, "3": [] };
+
+ fail("when comparing arguments to array", [1, 2, {}, []], gather(1, 2, {}, []));
+ fail("when comparing array to arguments", gather(), []);
+ fail("when comparing arguments to array like object",
+ arrayLike, gather(1, 2, {}, []));
+
+ msg("fail with understandable message",
+ "[refute.equals] [object Object] expected not to be equal to [object Object]", {}, {});
+
+ msg("fail with custom message",
+ "[refute.equals] Eh? [object Object] expected not to be equal to [object Object]",
+ {}, {}, "Eh?");
+ });
+
+ testHelper.assertionTests("assert", "greater", function (pass, fail, msg) {
+ pass("when greater than", 2, 1);
+ fail("when equal", 1, 1);
+ fail("when less than", 0, 1);
+ msg(
+ "fail with descriptive message",
+ "[assert.greater] Expected 1 to be greater than 2",
+ 1,
+ 2
+ );
+ });
+
+ testHelper.assertionTests("refute", "greater", function (pass, fail, msg) {
+ fail("when greater than", 2, 1);
+ pass("when equal", 1, 1);
+ pass("when less than", 0, 1);
+ msg(
+ "fail with descriptive message",
+ "[refute.greater] Expected 2 to be less than or equal to 1",
+ 2,
+ 1
+ );
+ });
+
+ testHelper.assertionTests("assert", "less", function (pass, fail, msg) {
+ fail("when greater than", 2, 1);
+ fail("when equal", 1, 1);
+ pass("when less than", 0, 1);
+ msg(
+ "fail with descriptive message",
+ "[assert.less] Expected 2 to be less than 1",
+ 2,
+ 1
+ );
+ });
+
+ testHelper.assertionTests("refute", "less", function (pass, fail, msg) {
+ pass("when greater than", 2, 1);
+ pass("when equal", 1, 1);
+ fail("when less than", 0, 1);
+ msg(
+ "fail with descriptive message",
+ "[refute.less] Expected 1 to be greater than or equal to 2",
+ 1,
+ 2
+ );
+ });
+
+ testHelper.assertionTests("assert", "isString", function (pass, fail, msg) {
+ pass("for string", "Hey");
+ fail("for object", {});
+ msg("fail with descriptive message",
+ "[assert.isString] Expected [object Object] (object) to be string",
+ {});
+ msg("fail with custom message",
+ "[assert.isString] Snap: Expected [object Object] (object) to be string",
+ {}, "Snap");
+ });
+
+ testHelper.assertionTests("refute", "isString", function (pass, fail, msg) {
+ fail("for string", "Hey");
+ pass("for object", {});
+ msg("fail with descriptive message",
+ "[refute.isString] Expected Yo not to be string",
+ "Yo");
+ msg("fail with custom message",
+ "[refute.isString] Here goes: Expected Yo not to be string",
+ "Yo", "Here goes");
+ });
+
+ testHelper.assertionTests("assert", "isObject", function (pass, fail, msg) {
+ pass("for object", {});
+ fail("for function", function () {});
+ fail("for null", null);
+ msg("fail with descriptive message",
+ "[assert.isObject] Hey (string) expected to be object and not null",
+ "Hey");
+ msg("fail with custom message",
+ "[assert.isObject] OH! Hey (string) expected to be object and not null",
+ "Hey", "OH!");
+ });
+
+ testHelper.assertionTests("refute", "isObject", function (pass, fail, msg) {
+ fail("for object", {});
+ pass("for function", function () {});
+ pass("for null", null);
+ msg("fail with descriptive message",
+ "[refute.isObject] [object Object] expected to be null or not an object",
+ {});
+ msg("fail with custom message",
+ "[refute.isObject] Oh no! [object Object] expected to be null or not an object",
+ {}, "Oh no!");
+ });
+
+ testHelper.assertionTests("assert", "isFunction", function (pass, fail, msg) {
+ pass("for function", function () {});
+ fail("for object", {});
+ msg("fail with descriptive message",
+ "[assert.isFunction] Hey (string) expected to be function",
+ "Hey");
+ msg("fail with custom message",
+ "[assert.isFunction] Oh no: Hey (string) expected to be function",
+ "Hey", "Oh no");
+ });
+
+ testHelper.assertionTests("refute", "isFunction", function (pass, fail, msg) {
+ fail("for function", function () {});
+ pass("for object", {});
+ msg("fail with descriptive message",
+ "[refute.isFunction] function () {} expected not to be function",
+ function () {});
+ msg("fail with custom message",
+ "[refute.isFunction] Hmm: function () {} expected not to be function",
+ function () {}, "Hmm");
+ });
+
+ testHelper.assertionTests("assert", "isBoolean", function (pass, fail, msg) {
+ pass("for boolean", true);
+ fail("for function", function () {});
+ fail("for null", null);
+ msg("fail with descriptive message",
+ "[assert.isBoolean] Expected Hey (string) to be boolean", "Hey");
+ msg("fail with custom message",
+ "[assert.isBoolean] Boolean, plz: Expected Hey (string) to be boolean",
+ "Hey", "Boolean, plz");
+ });
+
+ testHelper.assertionTests("refute", "isBoolean", function (pass, fail, msg) {
+ fail("for boolean", true);
+ pass("for function", function () {});
+ pass("for null", null);
+ msg("fail with descriptive message",
+ "[refute.isBoolean] Expected true not to be boolean", true);
+ msg("fail with custom message",
+ "[refute.isBoolean] Here: Expected true not to be boolean",
+ true, "Here");
+ });
+
+ testHelper.assertionTests("assert", "isNumber", function (pass, fail, msg) {
+ pass("for number", 32);
+ fail("for NaN (sic)", NaN);
+ fail("for function", function () {});
+ fail("for null", null);
+ msg("fail with descriptive message",
+ "[assert.isNumber] Expected Hey (string) to be a non-NaN number",
+ "Hey");
+ msg("fail with custom message",
+ "[assert.isNumber] Check it: Expected Hey (string) to be a non-NaN number",
+ "Hey", "Check it");
+ });
+
+ testHelper.assertionTests("refute", "isNumber", function (pass, fail, msg) {
+ fail("for number", 32);
+ pass("for NaN (sic)", NaN);
+ pass("for function", function () {});
+ pass("for null", null);
+ msg("fail with descriptive message",
+ "[refute.isNumber] Ho ho! Expected 42 to be NaN or a non-number value",
+ 42, "Ho ho!");
+ });
+
+ testHelper.assertionTests("assert", "isNaN", function (pass, fail, msg) {
+ pass("for NaN", NaN);
+ fail("for number", 32);
+ fail("for function", function () {});
+ fail("for object", {});
+ fail("for null", null);
+ msg("fail with descriptive message", "[assert.isNaN] Expected 32 to be NaN", 32);
+ msg("fail with custom message", "[assert.isNaN] No! Expected 32 to be NaN",
+ 32, "No!");
+ });
+
+ testHelper.assertionTests("refute", "isNaN", function (pass, fail, msg) {
+ fail("for NaN", NaN);
+ pass("for number", 32);
+ pass("for function", function () {});
+ pass("for object", {});
+ pass("for null", null);
+ msg("fail with descriptive message",
+ "[refute.isNaN] Expected not to be NaN", NaN);
+ msg("fail with custom message",
+ "[refute.isNaN] Hey: Expected not to be NaN", NaN, "Hey");
+ });
+
+ testHelper.assertionTests("assert", "isArray", function (pass, fail, msg) {
+ function captureArgs() {
+ return arguments;
+ }
+
+ var arrayLike = {
+ length: 4,
+ "0": "One",
+ "1": "Two",
+ "2": "Three",
+ "3": "Four",
+ splice: function () {}
+ };
+
+ pass("for array", []);
+ fail("for object", {});
+ fail("for arguments", captureArgs());
+ fail("for array like", arrayLike);
+ msg("fail with descriptive message",
+ "[assert.isArray] Expected [object Object] to be array", {});
+ msg("fail with custom message",
+ "[assert.isArray] Nope: Expected [object Object] to be array",
+ {}, "Nope");
+ });
+
+ testHelper.assertionTests("refute", "isArray", function (pass, fail, msg) {
+ function captureArgs() {
+ return arguments;
+ }
+
+ var arrayLike = {
+ length: 4,
+ "0": "One",
+ "1": "Two",
+ "2": "Three",
+ "3": "Four",
+ splice: function () {}
+ };
+
+ fail("for array", []);
+ pass("for object", {});
+ pass("for arguments", captureArgs());
+ pass("for array like", arrayLike);
+ msg("fail with descriptive message",
+ "[refute.isArray] Expected 1,2 not to be array", [1, 2]);
+ msg("fail with custom message",
+ "[refute.isArray] Hmm: Expected 1,2 not to be array",
+ [1, 2], "Hmm");
+ });
+
+ testHelper.assertionTests("assert", "isArrayLike", function (pass, fail, msg) {
+ function captureArgs() { return arguments; }
+
+ var arrayLike = {
+ length: 4,
+ "0": "One",
+ "1": "Two",
+ "2": "Three",
+ "3": "Four",
+ splice: function () {}
+ };
+
+ pass("for array", []);
+ fail("for object", {});
+ pass("for arguments", captureArgs());
+ pass("for array like", arrayLike);
+ msg("fail with descriptive message",
+ "[assert.isArrayLike] Expected [object Object] to be array like", {});
+ msg("fail with custom message",
+ "[assert.isArrayLike] Here! Expected [object Object] to be array like",
+ {}, "Here!");
+ });
+
+ testHelper.assertionTests("refute", "isArrayLike", function (pass, fail, msg) {
+ function captureArgs() { return arguments; }
+
+ var arrayLike = {
+ length: 4,
+ "0": "One",
+ "1": "Two",
+ "2": "Three",
+ "3": "Four",
+ splice: function () {}
+ };
+
+ fail("for array", []);
+ pass("for object", {});
+ fail("for arguments", captureArgs());
+ fail("for array like", arrayLike);
+ msg("fail with descriptive message",
+ "[refute.isArrayLike] Expected 1,2 not to be array like", [1, 2]);
+ msg("fail with custom message",
+ "[refute.isArrayLike] Hey: Expected 1,2 not to be array like",
+ [1, 2], "Hey");
+ });
+
+ testHelper.assertionTests("assert", "defined", function (pass, fail, msg) {
+ fail("for undefined", undefined);
+ pass("for function", function () {});
+ pass("for null", null);
+ msg("fail with descriptive message",
+ "[assert.defined] Expected to be defined", undefined);
+ msg("fail with custom message",
+ "[assert.defined] Huh? Expected to be defined",
+ undefined, "Huh?");
+ });
+
+ testHelper.assertionTests("refute", "defined", function (pass, fail, msg) {
+ pass("for undefined", undefined);
+ fail("for function", function () {});
+ fail("for null", null);
+ msg("fail with descriptive message",
+ "[refute.defined] Expected Hey (string) not to be defined",
+ "Hey");
+ msg("fail with custom message",
+ "[refute.defined] Yawn... Expected Hey (string) not to be defined",
+ "Hey", "Yawn...");
+ });
+
+ testHelper.assertionTests("assert", "isNull", function (pass, fail, msg) {
+ pass("for null", null);
+ fail("for function", function () {});
+ fail("for undefined", undefined);
+ msg("fail with descriptive message",
+ "[assert.isNull] Expected Hey to be null", "Hey").expectedFormats = 1;
+ msg("fail with custom message",
+ "[assert.isNull] Hmm: Expected Hey to be null",
+ "Hey", "Hmm").expectedFormats = 1;
+ });
+
+ testHelper.assertionTests("refute", "isNull", function (pass, fail, msg) {
+ fail("for null", null);
+ pass("for function", function () {});
+ pass("for undefined", undefined);
+ msg("fail with descriptive message",
+ "[refute.isNull] Expected not to be null", null).expectedFormats = 0;
+ msg("fail with custom message",
+ "[refute.isNull] Here: Expected not to be null",
+ null, "Here").expectedFormats = 0;
+ });
+
+ testHelper.assertionTests("assert", "match", function (pass, fail, msg) {
+ pass("matching regexp", "Assertions", /[a-z]/);
+ pass("for generic object with test method returning true", "Assertions", {
+ test: function () {
+ return true;
+ }
+ });
+
+ fail("for non-matching regexp", "Assertions 123", /^[a-z]$/);
+ pass("matching boolean", true, true);
+ fail("mis-matching boolean", true, false);
+
+ fail("for generic object with test method returning false", {
+ test: function () {
+ return false;
+ }
+ }, "Assertions");
+
+ msg("fail with understandable message",
+ "[assert.match] Assertions 123 expected to match /^[a-z]+$/",
+ "Assertions 123", /^[a-z]+$/);
+
+ msg("fail with custom message",
+ "[assert.match] Yeah! Assertions 123 expected to match /^[a-z]+$/",
+ "Assertions 123", /^[a-z]+$/, "Yeah!");
+
+ fail("if match object is null", "Assertions 123", null);
+
+ fail("if match object is undefined", "Assertions 123", undefined);
+
+ fail("with custom message if match object is undefined",
+ "Assertions 123", undefined, "No");
+
+ fail("if match object is false", "Assertions 123", false);
+ fail("if matching a number against a string", "Assertions 123", 23);
+ fail("if matching a number against a similar string", "23", 23);
+ pass("if matching a number against itself", 23, 23);
+
+ pass("if matcher is a function that returns true",
+ "Assertions 123", function (obj) { return true; });
+
+ fail("if matcher is a function that returns false",
+ "Assertions 123", function (obj) { return false; });
+
+ fail("if matcher is a function that returns falsy",
+ "Assertions 123", function () {});
+
+ fail("if matcher does not return explicit true",
+ "Assertions 123", function () { return "Hey"; });
+
+ this["should call matcher with assertion argument"] = function () {
+ var listener = this.stub().returns(true);
+
+ referee.assert.match("Assertions 123", listener);
+
+ assert.calledWith(listener, "Assertions 123");
+ };
+
+ pass("if matcher is substring of matchee", "Diskord", "or");
+ pass("if matcher is string equal to matchee", "Diskord", "Diskord");
+ pass("for strings ignoring case", "Look ma, case-insensitive",
+ "LoOk Ma, CaSe-InSenSiTiVe");
+
+ fail("if match string is not substring of matchee", "Vim", "Emacs");
+ fail("if match string is not substring of object", {}, "Emacs");
+
+ fail("if matcher is substring of object.toString", "Emacs", {
+ toString: function () {
+ return "Emacs";
+ }
+ });
+
+ fail("for null and empty string", null, "");
+ fail("for undefined and empty string", undefined, "");
+ fail("for false and empty string", false, "");
+ fail("for 0 and empty string", 0, "");
+ fail("for NaN and empty string", NaN, "");
+
+ var object = {
+ id: 42,
+ name: "Christian",
+ doIt: "yes",
+
+ speak: function () {
+ return this.name;
+ }
+ };
+
+ pass("if object contains all properties in matcher", object, {
+ id: 42,
+ doIt: "yes"
+ });
+
+ var object2 = {
+ id: 42,
+ name: "Christian",
+ doIt: "yes",
+ owner: {
+ someDude: "Yes",
+ hello: "ok"
+ },
+
+ speak: function () {
+ return this.name;
+ }
+ };
+
+ pass("for nested matcher", object2, {
+ owner: {
+ someDude: "Yes",
+ hello: function (value) {
+ return value === "ok";
+ }
+ }
+ });
+
+ pass("for empty strings", "", "");
+ pass("for empty strings as object properties", { foo: "" }, { foo: "" });
+ pass("for similar arrays", [1, 2, 3], [1, 2, 3]);
+ pass("for array subset", [1, 2, 3], [2, 3]);
+ pass("for single-element array subset", [1, 2, 3], [1]);
+ pass("for matching array subset", [1, 2, 3, { id: 42 }], [{ id: 42 }]);
+ fail("for mis-matching array 'subset'", [1, 2, 3], [2, 3, 4]);
+ fail("for mis-ordered array 'subset'", [1, 2, 3], [1, 3]);
+ });
+
+ testHelper.assertionTests("refute", "match", function (pass, fail, msg) {
+ fail("matching regexp", "Assertions", /[a-z]/);
+ fail("generic object with test method returning true", "Assertions", {
+ test: function () {
+ return true;
+ }
+ });
+
+ pass("for non-matching regexp", "Assertions 123", /^[a-z]$/);
+
+ pass("for generic object with test method returning false", "Assertions", {
+ test: function () {
+ return false;
+ }
+ });
+
+ msg("fail with understandable message",
+ "[refute.match] Assertions 123 expected not to match /^.+$/",
+ "Assertions 123", /^.+$/);
+ msg("fail with custom message",
+ "[refute.match] NO! Assertions 123 expected not to match /^.+$/",
+ "Assertions 123", /^.+$/, "NO!");
+
+ pass("if match object is null", "Assertions 123", null);
+ pass("if match object is undefined", "Assertions 123", undefined);
+ pass("if match object is false", "Assertions 123", false);
+ pass("if matching a number against a string", "Assertions 123", 23);
+ fail("if matching a number against a similar string", 23, "23");
+ fail("if matching a number against itself", 23, 23);
+ fail("if matcher is a function that returns true", "Assertions 123",
+ function (obj) { return true; });
+
+ pass("if matcher is a function that returns false",
+ "Assertions 123", function (obj) { return false; });
+
+ pass("if matcher is a function that returns falsy",
+ "Assertions 123", function () {});
+
+ pass("if matcher does not return explicit true",
+ "Assertions 123", function () { return "Hey"; });
+
+ this["should call matcher with assertion argument"] = function () {
+ var listener = this.stub().returns(false);
+
+ referee.refute.match("Assertions 123", listener);
+
+ assert.calledWith(listener, "Assertions 123");
+ };
+
+ fail("if matcher is substring of matchee", "Diskord", "or");
+ fail("if matcher is string equal to matchee", "Diskord", "Diskord");
+ pass("if match string is not substring of matchee", "Vim", "Emacs");
+ pass("if match string is not substring of object", {}, "Emacs");
+
+ pass("if matcher is substring of object.toString", "Emacs", {
+ toString: function () {
+ return "Emacs";
+ }
+ });
+
+ pass("if matching an empty string with null", null, "");
+ pass("if matching an empty string with undefined", undefined, "");
+ pass("if matching an empty string with false", false, "");
+ pass("if matching an empty string with 0", 0, "");
+ pass("if matching an empty string with NaN", NaN, "");
+
+ var object = {
+ id: 42,
+ name: "Christian",
+ doIt: "yes",
+
+ speak: function () {
+ return this.name;
+ }
+ };
+
+ fail("if object contains all properties in matcher", object, {
+ id: 42,
+ doIt: "yes"
+ });
+
+ var object2 = {
+ id: 42,
+ name: "Christian",
+ doIt: "yes",
+ owner: {
+ someDude: "Yes",
+ hello: "ok"
+ },
+
+ speak: function () {
+ return this.name;
+ }
+ };
+
+ fail("for nested matcher", object2, {
+ owner: {
+ someDude: "Yes",
+ hello: function (value) {
+ return value === "ok";
+ }
+ }
+ });
+
+ var object3 = {
+ id: 42,
+ name: "Christian",
+ doIt: "yes",
+ owner: {
+ someDude: "Yes",
+ hello: "ok"
+ },
+
+ speak: function () {
+ return this.name;
+ }
+ };
+
+ pass("for nested matcher with mismatching properties", object3, {
+ owner: {
+ someDude: "No",
+ hello: function (value) {
+ return value === "ok";
+ }
+ }
+ });
+
+ fail("for similar arrays", [1, 2, 3], [1, 2, 3]);
+ fail("for array subset", [1, 2, 3], [2, 3]);
+ fail("for single-element array subset", [1, 2, 3], [1]);
+ fail("for matching array subset", [1, 2, 3, { id: 42 }], [{ id: 42 }]);
+ pass("for mis-matching array 'subset'", [1, 2, 3], [2, 3, 4]);
+ pass("for mis-ordered array 'subset'", [1, 2, 3], [1, 3]);
+ });
+
+ testHelper.assertionTests("assert", "keys", function (pass, fail, msg) {
+ function Class(o) {
+ for (var key in o) {
+ if (o.hasOwnProperty(key)) {
+ this[key] = o[key];
+ }
+ }
+ }
+ Class.prototype.methodA = function () {};
+ Class.prototype.methodB = function () {};
+
+ pass("when keys are exact", {a: 1, b: 2, c: 3}, ['a', 'b', 'c']);
+ fail("when keys are missing", {a: 1, b: 2, c: 3}, ['a', 'b']);
+ fail("when keys are excess", {a: 1, b: 2, c: 3}, ['a', 'b', 'c', 'd']);
+ fail("when keys are not exact", {a: 1, b: 2, c: 3}, ['a', 'b', 'd']);
+ pass("when there are no keys", {}, []);
+ pass("when values are special", {a: -1, b: null, c: undefined}, ['a', 'b', 'c']);
+ pass("and ignore object methods", new Class({a: 1, b: 2, c: 3}), ['a', 'b', 'c']);
+ pass("and allow overwriting object methods",
+ new Class({a: 1, methodA: 2}), ['a', 'methodA']);
+
+ msg("fail with message",
+ "[assert.keys] Expected [object Object] to have exact keys a,b",
+ {a: 1, b: 2, c: 3}, ['a', 'b']);
+
+ msg("fail with custom message",
+ "[assert.keys] Too bad: Expected [object Object] to have exact keys a,b",
+ {a: 1, b: 2, c: 3}, ['a', 'b'], "Too bad");
+ });
+
+ testHelper.assertionTests("refute", "keys", function (pass, fail, msg) {
+ function Class(o) {
+ for (var key in o) {
+ if (o.hasOwnProperty(key)) {
+ this[key] = o[key];
+ }
+ }
+ }
+ Class.prototype.methodA = function () {};
+ Class.prototype.methodB = function () {};
+
+ fail("when keys are exact", {a: 1, b: 2, c: 3}, ['a', 'b', 'c']);
+ pass("when keys are missing", {a: 1, b: 2, c: 3}, ['a', 'b']);
+ pass("when keys are excess", {a: 1, b: 2, c: 3}, ['a', 'b', 'c', 'd']);
+ pass("when keys are not exact", {a: 1, b: 2, c: 3}, ['a', 'b', 'd']);
+ fail("when there are no keys", {}, []);
+ fail("when values are special", {a: -1, b: null, c: undefined}, ['a', 'b', 'c']);
+ fail("and ignore object methods", new Class({a: 1, b: 2, c: 3}), ['a', 'b', 'c']);
+ fail("and allow overwriting object methods",
+ new Class({a: 1, methodA: 2}), ['a', 'methodA']);
+
+ msg("fail with message",
+ "[refute.keys] Expected not to have exact keys a,b,c",
+ {a: 1, b: 2, c: 3}, ['a', 'b', 'c']);
+
+ msg("fail with custom message",
+ "[refute.keys] Too bad: Expected not to have exact keys a,b,c",
+ {a: 1, b: 2, c: 3}, ['a', 'b', 'c'], "Too bad");
+ });
+
+ testHelper.assertionTests("assert", "exception", function (pass, fail, msg) {
+ pass("when callback throws", function () { throw new Error(); });
+ fail("when callback does not throw", function () {});
+
+ msg("fail with message", "[assert.exception] Expected exception",
+ function () {}).expectedFormats = 0;
+
+ pass("when callback throws expected name", function () {
+ throw new TypeError("Oh hmm");
+ }, { name: "TypeError" });
+
+ fail("when callback does not throw expected name", function () {
+ throw new Error();
+ }, { name: "TypeError" });
+
+ fail("when thrown message does not match", function () {
+ throw new Error("Aright");
+ }, { message: "Aww" });
+
+ pass("when message and type matches", function () {
+ throw new TypeError("Aright");
+ }, { name: "Type", message: "Ar" });
+
+ fail("when callback does not throw and specific type is expected",
+ function () {}, { name: "TypeError" });
+
+ msg("fail with message when not throwing",
+ "[assert.exception] Expected [object Object] but no exception was thrown",
+ function () {}, { name: "TypeError" }).expectedFormats = 1;
+
+ msg("fail with custom message",
+ "[assert.exception] Hmm: Expected exception",
+ function () {}, "Hmm").expectedFormats = 0;
+
+ msg("fail with matcher and custom message",
+ "[assert.exception] Hmm: Expected [object Object] but no exception was thrown",
+ function () {}, { name: "TypeError" }, "Hmm").expectedFormats = 1;
+
+ pass("when matcher function returns true", function () {
+ throw new TypeError("Aright");
+ }, function (err) { return err.name === "TypeError"; });
+
+ fail("when matcher function returns truthy", function () {
+ throw new TypeError("Aright");
+ }, function (err) { return err.name; });
+
+ fail("when matcher function returns false", function () {
+ throw new TypeError("Aright");
+ }, function (err) { return err.name === "Error"; });
+
+ msg("when matcher function fails",
+ "[assert.exception] Expected thrown TypeError (Aright) to pass matcher function",
+ function () {
+ throw new TypeError("Aright");
+ }, function (err) { return err.name === "Error"; }).expectedFormats = 0;
+
+ msg("if not passed arguments",
+ "[assert.exception] Expected to receive at least 1 argument");
+ });
+
+ 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) {
+ fail("when callback throws", function () {
+ throw new Error("Yo, Malcolm");
+ });
+
+ pass("when callback does not throw", function () {});
+ pass("with message when callback does not throw", function () {}, "Oh noes");
+
+ msg("fail with message",
+ "[refute.exception] Expected not to throw but threw Error (:()",
+ function () { throw new Error(":("); });
+
+ msg("fail with custom message",
+ "[refute.exception] Jeez: Expected not to throw but threw Error (:()",
+ function () {
+ throw new Error(":(");
+ }, "Jeez");
+
+ msg("fail if not passed arguments",
+ "[refute.exception] Expected to receive at least 1 argument");
+ });
+
+ testHelper.assertionTests("assert", "tagName", function (pass, fail, msg) {
+ pass("for matching tag names", { tagName: "li" }, "li");
+ pass("for case-insensitive matching tag names", { tagName: "LI" }, "li");
+ pass("for case-insensitive matching tag names #2", { tagName: "li" }, "LI");
+ pass("for uppercase matching tag names", { tagName: "LI" }, "LI");
+ fail("for non-matching tag names", { tagName: "li" }, "p");
+ fail("for substring matches in tag names", { tagName: "li" }, "i");
+
+ msg("fail with message",
+ "[assert.tagName] Expected tagName to be p but was li",
+ { tagName: "li" }, "p");
+
+ msg("fail with custom message",
+ "[assert.tagName] Here: Expected tagName to be p but was li",
+ { tagName: "li" }, "p", "Here");
+
+ msg("fail if not passed arguments",
+ "[assert.tagName] Expected to receive at least 2 arguments");
+
+ msg("fail if not passed tag name",
+ "[assert.tagName] Expected to receive at least 2 arguments",
+ { tagName: ""}).expectedFormats = 0;
+
+ msg("fail if object does not have tagName property",
+ "[assert.tagName] Expected [object Object] to have tagName property",
+ {}, "li");
+
+ msg("fail with custom message if object does not have tagName property",
+ "[assert.tagName] Yikes! Expected [object Object] to have tagName property",
+ {}, "li", "Yikes!");
+
+ if (typeof document !== "undefined") {
+ pass("for DOM elements", document.createElement("li"), "li");
+ }
+ });
+
+ testHelper.assertionTests("refute", "tagName", function (pass, fail, msg) {
+ fail("for matching tag names", { tagName: "li" }, "li");
+ fail("for case-insensitive matching tag names", { tagName: "LI" }, "li");
+ fail("for case-insensitive matching tag names #2", { tagName: "LI" }, "li");
+ fail("for same casing matching tag names", { tagName: "li" }, "li");
+ pass("for non-matching tag names", { tagName: "li" }, "p");
+ pass("for substring matching tag names", { tagName: "li" }, "i");
+ pass("for case-insensitive non-matching tag names", { tagName: "li" }, "P");
+ pass("for case-insensitive substring mathcing tag names",
+ { tagName: "li" }, "i");
+
+ msg("fail with message",
+ "[refute.tagName] Expected tagName not to be li",
+ { tagName: "li" }, "li");
+
+ msg("fail with custom message",
+ "[refute.tagName] Oh well: Expected tagName not to be li",
+ { tagName: "li" }, "li", "Oh well");
+
+ msg("fail if not passed arguments",
+ "[refute.tagName] Expected to receive at least 2 arguments");
+
+ msg("fail if not passed tag name",
+ "[refute.tagName] Expected to receive at least 2 arguments",
+ { tagName: "p" }).expectedFormats = 0;
+
+ msg("fail if object does not have tagName property",
+ "[refute.tagName] Expected [object Object] to have tagName property",
+ {}, "li");
+
+ msg("fail with custom message if object does not have tagName property",
+ "[refute.tagName] Yes: Expected [object Object] to have tagName property",
+ {}, "li", "Yes");
+
+ if (typeof document !== "undefined") {
+ pass("for DOM elements", document.createElement("li"), "p");
+ }
+ });
+
+ testHelper.assertionTests("assert", "className", function (pass, fail, msg) {
+ msg("fail without arguments",
+ "[assert.className] Expected to receive at least 2 arguments");
+
+ msg("fail without class name",
+ "[assert.className] Expected to receive at least 2 arguments",
+ { className: "" }).expectedFormats = 0;
+
+ msg("fail if object does not have className property",
+ "[assert.className] Expected object to have className property",
+ {}, "item");
+
+ msg("fail with custom message if object does not have className property",
+ "[assert.className] Nope: Expected object to have className property",
+ {}, "item", "Nope");
+
+ msg("fail when element does not include class name",
+ "[assert.className] Expected object's className to include item but was ",
+ { className: "" }, "item");
+
+ msg("fail with custom message when element does not include class name",
+ "[assert.className] Come on! Expected object's className to include item but was ",
+ { className: "" }, "item", "Come on!");
+
+ pass("when element's class name matches", { className: "item" }, "item");
+ pass("when element includes class name", { className: "feed item" }, "item");
+ fail("when element does not include all class names",
+ { className: "feed item" }, "item post");
+
+ pass("when element includes all class names",
+ { className: "feed item post" }, "item post");
+
+ pass("when element includes all class names in different order",
+ { className: "a b c d e" }, "e a d");
+
+ pass("with class names as array", { className: "a b c d e" }, ["e", "a", "d"]);
+
+ if (typeof document !== "undefined") {
+ var li = document.createElement("li");
+ li.className = "some thing in here";
+
+ pass("for DOM elements", li, "thing some");
+ }
+ });
+
+ testHelper.assertionTests("refute", "className", function (pass, fail, msg) {
+ msg("fail without arguments",
+ "[refute.className] Expected to receive at least 2 arguments");
+
+ msg("fail without class name",
+ "[refute.className] Expected to receive at least 2 arguments",
+ { className: "item" }).expectedFormats = 0;
+
+ msg("fail if object does not have className property",
+ "[refute.className] Expected object to have className property",
+ {}, "item");
+
+ msg("fail with custom message if object does not have className property",
+ "[refute.className] Yikes: Expected object to have className property",
+ {}, "item", "Yikes");
+
+ pass("when element does not include class name", { className: "" }, "item");
+
+ msg("fail when element's class name matches",
+ "[refute.className] Expected object's className not to include item",
+ { className: "item" }, "item");
+
+ msg("fail with custom message when element's class name matches",
+ "[refute.className] Noes: Expected object's className not to include item",
+ { className: "item" }, "item", "Noes");
+
+ fail("when element includes class name", { className: "feed item" }, "item");
+ pass("when element does not include all class names",
+ { className: "feed item" }, "item post");
+ fail("when element includes all class names",
+ { className: "feed item post" }, "item post");
+ fail("when element includes all class names in different order",
+ { className: "a b c d e" }, "e a d");
+ fail("with class names as array", { className: "a b c d e" }, ["e", "a", "d"]);
+ pass("with class names as array", { className: "a b c d e" }, ["f", "a", "d"]);
+
+ if (typeof document !== "undefined") {
+ var li = document.createElement("li");
+ li.className = "some thing in here";
+
+ pass("for DOM elements", li, "something");
+ }
+ });
+
+ testHelper.assertionTests("assert", "near", function (pass, fail, msg) {
+ pass("for equal numbers", 3, 3, 0);
+ fail("for numbers out of delta range", 2, 3, 0.5);
+ msg("fail with descriptive message",
+ "[assert.near] Expected 3 to be equal to 2 +/- 0.6", 3, 2, 0.6);
+ msg("fail with custom message",
+ "[assert.near] Ho! Expected 3 to be equal to 2 +/- 0.6",
+ 3, 2, 0.6, "Ho!");
+ pass("for numbers in delta range", 2, 3, 1);
+ msg("fail if not passed arguments",
+ "[assert.near] Expected to receive at least 3 arguments");
+ });
+
+ testHelper.assertionTests("refute", "near", function (pass, fail, msg) {
+ fail("for equal numbers", 3, 3, 0);
+ pass("for numbers out of delta range", 2, 3, 0.5);
+ msg("with descriptive message",
+ "[refute.near] Expected 3 not to be equal to 3 +/- 0", 3, 3, 0);
+ msg("with custom message",
+ "[refute.near] Hey: Expected 3 not to be equal to 3 +/- 0",
+ 3, 3, 0, "Hey");
+ fail("for numbers in delta range", 2, 3, 1);
+ msg("fail if not passed arguments",
+ "[refute.near] Expected to receive at least 3 arguments");
+ });
+
+ function MyThing() {}
+ var myThing = new MyThing();
+ var otherThing = {};
+ function F() {}
+ F.prototype = myThing;
+ var specializedThing = new F();
+
+ testHelper.assertionTests("assert", "hasPrototype", function (pass, fail, msg) {
+ fail("when object does not inherit from prototype", otherThing, MyThing.prototype);
+ fail("when primitive does not inherit from prototype", 3, MyThing.prototype);
+ fail("with only one object", {});
+ pass("when object has other object on prototype chain", myThing, MyThing.prototype);
+ pass("when not directly inheriting", specializedThing, MyThing.prototype);
+ msg("with descriptive message",
+ "[assert.hasPrototype] Expected [object Object] to have [object Object] on its prototype chain", otherThing, MyThing.prototype);
+ msg("with custom message",
+ "[assert.hasPrototype] Oh: Expected [object Object] to have [object Object] on its prototype chain",
+ otherThing, MyThing.prototype, "Oh");
+ msg("fail if not passed arguments",
+ "[assert.hasPrototype] Expected to receive at least 2 arguments");
+ });
+
+ testHelper.assertionTests("refute", "hasPrototype", function (pass, fail, msg) {
+ fail("when object inherits from prototype", myThing, MyThing.prototype);
+ fail("when not inheriting 'indirectly'", specializedThing, MyThing.prototype);
+ fail("with only one object", {});
+ pass("when primitive does not inherit from prototype", 3, MyThing.prototype);
+ pass("when object does not inherit", otherThing, MyThing.prototype);
+ msg("with descriptive message",
+ "[refute.hasPrototype] Expected [object Object] not to have [object Object] on its prototype chain", myThing, MyThing.prototype);
+ msg("with descriptive message",
+ "[refute.hasPrototype] Oh: Expected [object Object] not to have [object Object] on its prototype chain",
+ myThing, MyThing.prototype, "Oh");
+ msg("fail if not passed arguments",
+ "[refute.hasPrototype] Expected to receive at least 2 arguments");
+ });
+
+ testHelper.assertionTests("assert", "contains", function (pass, fail, msg) {
+ pass("when array contains value", [0, 1, 2], 1);
+ fail("when array does not contain value", [0, 1, 2], 3);
+ msg("with descriptive message",
+ "[assert.contains] Expected [0,1,2] to contain 3", [0, 1, 2], 3);
+ var thing = {};
+ var otherThing = {};
+ pass("when array contains the actual object", [thing], thing);
+ fail("when array contains different object with same value",
+ [thing], otherThing);
+ });
+
+ testHelper.assertionTests("refute", "contains", function (pass, fail, msg) {
+ fail("when array contains value", [0, 1, 2], 1);
+ pass("when array does not contain value", [0, 1, 2], 3);
+ msg("with descriptive message",
+ "[refute.contains] Expected [0,1,2] not to contain 2", [0, 1, 2], 2);
+ var thing = {};
+ var otherThing = {};
+ fail("when array contains the actual object", [thing], thing);
+ pass("when array contains different object with same value",
+ [thing], otherThing);
+ });
+
+ buster.testCase("CustomAssertionsTest", {
+ setUp: testHelper.setUp,
+ tearDown: function () {
+ testHelper.tearDown.call(this);
+ delete referee.assert.custom;
+ delete referee.refute.custom;
+ },
+
+ "should expose properties on this as message values": function () {
+ referee.add("custom", {
+ assert: function (actual, expected) {
+ this.actual = actual + "?";
+ this.expected = expected + "!";
+ return false;
+ },
+ assertMessage: "${actual} ${expected}"
+ });
+
+ try {
+ referee.assert.custom(2, 3);
+ throw new Error("Didn't throw");
+ } catch (e) {
+ assert.equals("[assert.custom] 2? 3!", e.message);
+ }
+ },
+
+ "should format interpolated property with format": function () {
+ referee.add("custom", {
+ assert: function (actual, expected) {
+ this.actual = actual + "?";
+ this.expected = expected + "!";
+ return false;
+ },
+ assertMessage: "${actual} ${expected}"
+ });
+
+ try {
+ referee.assert.custom(2, 3);
+ } catch (e) {}
+
+ assert.calledWith(referee.format, "2?");
+ assert.calledWith(referee.format, "3!");
+ },
+
+ "should not expose fail property": function () {
+ referee.add("custom", {
+ assert: function (actual, expected) {
+ return false;
+ },
+ assertMessage: "${fail}"
+ });
+
+ try {
+ referee.assert.custom(2, 3);
+ throw new Error("Didn't throw");
+ } catch (e) {
+ assert.equals("[assert.custom] ${fail}", e.message);
+ }
+ },
+
+ "should not leak properties between calls": function () {
+ var i = 0;
+
+ referee.add("custom", {
+ assert: function (actual, expected) {
+ if (i === 0) {
+ this.actual = "A";
+ } else {
+ this.expected = "B";
+ }
+
+ i++;
+ return false;
+ },
+ assertMessage: "${actual} ${expected}"
+ });
+
+ try {
+ referee.assert.custom(4, 5);
+ } catch (e) {}
+
+ try {
+ referee.assert.custom(2, 3);
+ throw new Error("Didn't throw");
+ } catch (err) {
+ assert.equals("[assert.custom] ${actual} B", err.message);
+ }
+ },
+
+ "should interpolate same property multiple times": function () {
+ referee.add("custom", {
+ assert: function (actual, expected) {
+ this.actual = actual + "?";
+ return false;
+ },
+ assertMessage: "${actual} ${actual}"
+ });
+
+ try {
+ referee.assert.custom(2, 3);
+ throw new Error("Didn't throw");
+ } catch (e) {
+ assert.equals("[assert.custom] 2? 2?", e.message);
+ }
+ },
+
+ "should interpolate numeric placeholders multiple times": function () {
+ referee.add("custom", {
+ assert: function (actual, expected) {
+ this.actual = actual + "?";
+ return false;
+ },
+ assertMessage: "${0} ${0}"
+ });
+
+ try {
+ referee.assert.custom(2, 3);
+ throw new Error("Didn't throw");
+ } catch (e) {
+ assert.equals("[assert.custom] 2 2", e.message);
+ }
+ },
+
+ "should add expectation if expect property is set": function () {
+ referee.add("custom", {
+ assert: function (actual) {
+ return actual === "foo";
+ },
+ assertMessage: "Expected ${1} to be foo!",
+ refuteMessage: "Expected not to be foo!",
+ expectation: "toBeFoo"
+ });
+
+ refute.exception(function () {
+ referee.expect("foo").toBeFoo();
+ });
+ }
+ });
+}(this.referee, this.testHelper, this.buster));
\ No newline at end of file
diff --git a/debian/node_modules/referee/test/test-helper.js b/debian/node_modules/referee/test/test-helper.js
new file mode 100644
index 0000000..2c9b66c
--- /dev/null
+++ b/debian/node_modules/referee/test/test-helper.js
@@ -0,0 +1,206 @@
+var testHelper = (function (referee, buster) {
+ if (typeof module === "object" && typeof require === "function") {
+ referee = require("../lib/referee");
+ buster = require("buster");
+ }
+
+ var assert = buster.referee.assert;
+ var refute = buster.referee.refute;
+
+ function slice(args, index) {
+ return Array.prototype.slice.call(args, index);
+ }
+
+ function assertFailureEvent(callback) {
+ var fails = this.failListener.callCount;
+ var passes = this.okListener.callCount;
+ referee.throwOnFailure = false;
+
+ try {
+ callback();
+ } catch (e) {
+ assert.fail("Assertion threw when it should not: " + e.message);
+ }
+
+ assert.equals(this.failListener.callCount, fails + 1,
+ "Fail listener was not called once: " +
+ this.failListener.callCount - fails);
+ assert.equals(this.okListener.callCount, passes,
+ "Pass listener was unexpectedly called");
+ }
+
+ function assertionFailureEventTest(callback) {
+ return function () {
+ assertFailureEvent.call(this, callback);
+ };
+ }
+
+ function passingAssertionTest(type, assertion, args) {
+ return function () {
+ var initialCount = referee.count;
+ var callStr = type + "." + assertion + "(" + args.join(", ") + ")";
+
+ try {
+ referee[type][assertion].apply(referee, args);
+ } catch (e) {
+ if (typeof console !== "undefined") {
+ console.log("Failed: " + callStr);
+ } else {
+ buster.util.puts("Failed: " + callStr);
+ }
+ }
+
+ assert.equals(
+ this.okListener.callCount,
+ 1,
+ "Expected referee to emit the pass event once for " + callStr
+ );
+ assert.calledWith(this.okListener, type + "." + assertion);
+ assert.equals(referee.count - initialCount, 1);
+ refute.called(referee.fail);
+ refute.called(this.failListener);
+ };
+ }
+
+ function failingAssertionTest(type, assertion, args) {
+ return function () {
+ var initialCount = referee.count;
+ var callStr = type + "." + assertion + "(" + args.join(", ") + ")";
+
+ try {
+ referee[type][assertion].apply(referee, args);
+
+ if (typeof console !== "undefined") {
+ console.log("Unexpectedly passed: " + callStr);
+ } else {
+ buster.util.puts("Unexpectedly passed: " + callStr);
+ }
+ } catch (e) {}
+
+ assert.equals(
+ referee.fail.callCount,
+ 1,
+ "Expected referee.fail to be called once for " +
+ callStr + ", was called " + referee.fail.callCount +
+ " times"
+ );
+
+ assert.equals(referee.count - initialCount, 1);
+ refute.called(this.okListener);
+ assert.calledOnce(this.failListener);
+
+ assertFailureEvent.call(this, function () {
+ referee[type][assertion].apply(referee, args);
+ });
+ };
+ }
+
+ function assertionMessageTest(type, assertion, message, args) {
+ var test = function () {
+ var msg;
+
+ try {
+ referee[type][assertion].apply(referee, args);
+ throw new Error(type + "." + assertion + " expected to fail");
+ } catch (e) {
+ assert.equals(e.name, "AssertionError",
+ e.name + ": " + e.message);
+ assert.equals(
+ e.message,
+ message,
+ "Message was " + e.message + ", " + "expected " + message
+ );
+ msg = e.message;
+ }
+
+ var expected = test.expectedFormats;
+
+ if (typeof expected !== "number") {
+ expected = args.length;
+
+ if (typeof args[args.length - 1] === "string") {
+ expected -= 1;
+ }
+ }
+
+ assert(referee.format.callCount >= expected);
+
+ var i, l;
+ for (i = 0, l = expected; i < l; ++i) {
+ if (!isNaN(args[i]) || !isNaN(referee.format.args[i][0])) {
+ assert.calledWith(referee.format, args[i]);
+ }
+ }
+
+ assert.equals(this.failListener.args[0][0].name, "AssertionError");
+ assert.equals(this.failListener.args[0][0].message, msg);
+ };
+
+ return test;
+ }
+
+ function assertionTests(type, assertion, callback) {
+ var tests = {
+ setUp: testHelper.setUp,
+ tearDown: testHelper.tearDown
+ };
+
+ var prefix = type + "." + assertion + " should ";
+
+ function pass(name) {
+ tests[prefix + "pass " + name] = passingAssertionTest(
+ type,
+ assertion,
+ slice(arguments, 1),
+ name
+ );
+ }
+
+ function fail(name) {
+ tests[prefix + "fail " + name] =
+ failingAssertionTest(type, assertion, slice(arguments, 1));
+ }
+
+ function msg(name, message) {
+ tests[prefix + name] = assertionMessageTest(
+ type,
+ assertion,
+ message,
+ slice(arguments, 2)
+ );
+
+ return tests[prefix + name];
+ }
+
+ callback.call(tests, pass, fail, msg);
+ return buster.testCase(type + "." + assertion, tests);
+ }
+
+ return {
+ setUp: function () {
+ this.spy(referee, "fail");
+
+ referee.format = this.spy(function (object) {
+ return String(object);
+ });
+
+ this.okListener = this.spy();
+ referee.on("pass", this.okListener);
+ this.failListener = this.spy();
+ referee.on("failure", this.failListener);
+ },
+
+ tearDown: function () {
+ delete referee.listeners;
+ referee.count = 0;
+ delete referee.throwOnFailure;
+ },
+
+ assertionFailureEventTest: assertionFailureEventTest,
+ assertionTests: assertionTests
+ };
+}(this.referee, this.buster));
+
+if (typeof module === "object") {
+ module.exports = testHelper;
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-lolex.git
More information about the Pkg-javascript-commits
mailing list