Manage rest of test libs with npm

This commit is contained in:
John Firebaugh
2013-04-04 10:48:13 -07:00
parent d72ede2e2d
commit f3caa77057
7 changed files with 12 additions and 8157 deletions

View File

@@ -25,6 +25,10 @@
"uglify-js": "~2.2.5",
"mocha": "~1.9",
"mocha-phantomjs": "~1.1.1",
"chai": "~1.4",
"sinon": "~1.6",
"sinon-chai": "~2.3.1",
"happen": "~0.1.2",
"glob": "~3.1.21",
"js-yaml": "~2.0.3",
"request": "~2.16.2",

View File

@@ -9,11 +9,11 @@
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="lib/chai.js"></script>
<script src="lib/sinon.js"></script>
<script src="lib/sinon-chai.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="../node_modules/sinon/pkg/sinon.js"></script>
<script src="../node_modules/sinon-chai/lib/sinon-chai.js"></script>
<script src="../node_modules/happen/src/happen.js"></script>
<script src="lib/bind-shim.js"></script>
<script src="lib/happen.js"></script>
<!-- include source files here... -->
<script src='../js/lib/lodash.js'></script>

View File

@@ -9,11 +9,11 @@
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="lib/chai.js"></script>
<script src="lib/sinon.js"></script>
<script src="lib/sinon-chai.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="../node_modules/sinon/pkg/sinon.js"></script>
<script src="../node_modules/sinon-chai/lib/sinon-chai.js"></script>
<script src="../node_modules/happen/src/happen.js"></script>
<script src="lib/bind-shim.js"></script>
<script src="lib/happen.js"></script>
<!-- include source files here... -->
<script src='../iD.min.js'></script>

File diff suppressed because it is too large Load Diff

View File

@@ -1,123 +0,0 @@
!(function(context, $) {
var h = {};
// Make inheritance bearable: clone one level of properties
function extend(child, parent) {
for (var property in parent) {
if (typeof child[property] == 'undefined') {
child[property] = parent[property];
}
}
return child;
}
h.once = function(x, o) {
var evt;
if (o.type.slice(0, 3) === 'key') {
if (typeof Event === 'function') {
evt = new Event(o.type);
evt.keyCode = o.keyCode || 0;
evt.charCode = o.charCode || 0;
evt.shiftKey = o.shiftKey || false;
evt.metaKey = o.metaKey || false;
evt.ctrlKey = o.ctrlKey || false;
evt.altKey = o.altKey || false;
} else {
evt = document.createEvent('KeyboardEvent');
// https://developer.mozilla.org/en/DOM/event.initKeyEvent
// https://developer.mozilla.org/en/DOM/KeyboardEvent
evt[(evt.initKeyEvent) ? 'initKeyEvent'
: 'initKeyboardEvent'](
o.type, // in DOMString typeArg,
true, // in boolean canBubbleArg,
true, // in boolean cancelableArg,
null, // in nsIDOMAbstractView viewArg, Specifies UIEvent.view. This value may be null.
o.ctrlKey || false, // in boolean ctrlKeyArg,
o.altKey || false, // in boolean altKeyArg,
o.shiftKey || false, // in boolean shiftKeyArg,
o.metaKey || false, // in boolean metaKeyArg,
o.keyCode || 0, // in unsigned long keyCodeArg,
o.charCode || 0 // in unsigned long charCodeArg);
);
// Workaround for https://bugs.webkit.org/show_bug.cgi?id=16735
if (evt.ctrlKey != (o.ctrlKey || 0) ||
evt.altKey != (o.altKey || 0) ||
evt.shiftKey != (o.shiftKey || 0) ||
evt.metaKey != (o.metaKey || 0) ||
evt.keyCode != (o.keyCode || 0) ||
evt.charCode != (o.charCode || 0)) {
evt = document.createEvent('Event');
evt.initEvent(o.type, true, true);
evt.ctrlKey = o.ctrlKey || false;
evt.altKey = o.altKey || false;
evt.shiftKey = o.shiftKey || false;
evt.metaKey = o.metaKey || false;
evt.keyCode = o.keyCode || 0;
evt.charCode = o.charCode || 0;
}
}
} else {
evt = document.createEvent('MouseEvents');
// https://developer.mozilla.org/en/DOM/event.initMouseEvent
evt.initMouseEvent(o.type,
true, // canBubble
true, // cancelable
window, // 'AbstractView'
o.clicks || 0, // click count
o.screenX || 0, // screenX
o.screenY || 0, // screenY
o.clientX || 0, // clientX
o.clientY || 0, // clientY
o.ctrlKey || 0, // ctrl
o.altKey || false, // alt
o.shiftKey || false, // shift
o.metaKey || false, // meta
o.button || false, // mouse button
null // relatedTarget
);
}
x.dispatchEvent(evt);
};
var shortcuts = ['click', 'mousedown', 'mouseup', 'mousemove',
'mouseover', 'mouseout', 'keydown', 'keyup', 'keypress'],
s, i = 0;
while (s = shortcuts[i++]) {
h[s] = (function(s) {
return function(x, o) {
h.once(x, extend(o || {}, { type: s }));
};
})(s);
}
h.dblclick = function(x, o) {
h.once(x, extend(o || {}, {
type: 'dblclick',
clicks: 2
}));
};
this.happen = h;
// Export for nodejs
if (typeof module !== 'undefined') {
module.exports = this.happen;
}
// Provide jQuery plugin
if ($ && $.fn) {
$.fn.happen = function(o) {
if (typeof o === 'string') {
o = { type: o };
}
for (var i = 0; i < this.length; i++) {
happen.once(this[i], o);
}
return this;
};
}
})(this, (typeof jQuery !== 'undefined') ? jQuery : null);

View File

@@ -1,106 +0,0 @@
(function (sinonChai) {
"use strict";
// Module systems magic dance.
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// NodeJS
module.exports = sinonChai;
} else if (typeof define === "function" && define.amd) {
// AMD
define(function () {
return sinonChai;
});
} else {
// Other environment (usually <script> tag): plug in to global chai instance directly.
chai.use(sinonChai);
}
}(function sinonChai(chai, utils) {
"use strict";
var slice = Array.prototype.slice;
function isSpy(putativeSpy) {
return typeof putativeSpy === "function" &&
typeof putativeSpy.getCall === "function" &&
typeof putativeSpy.calledWithExactly === "function";
}
function isCall(putativeCall) {
return putativeCall && isSpy(putativeCall.proxy);
}
function assertCanWorkWith(assertion) {
if (!isSpy(assertion._obj) && !isCall(assertion._obj)) {
throw new TypeError(utils.inspect(assertion._obj) + " is not a spy or a call to a spy!");
}
}
function getMessages(spy, action, nonNegatedSuffix, always, args) {
var verbPhrase = always ? "always have " : "have ";
nonNegatedSuffix = nonNegatedSuffix || "";
spy = spy.proxy || spy;
function printfArray(array) {
return spy.printf.apply(spy, array);
}
return {
affirmative: printfArray(["expected %n to " + verbPhrase + action + nonNegatedSuffix].concat(args)),
negative: printfArray(["expected %n to not " + verbPhrase + action].concat(args))
};
}
function sinonProperty(name, action, nonNegatedSuffix) {
utils.addProperty(chai.Assertion.prototype, name, function () {
assertCanWorkWith(this);
var messages = getMessages(this._obj, action, nonNegatedSuffix, false);
this.assert(this._obj[name], messages.affirmative, messages.negative);
});
}
function createSinonMethodHandler(sinonName, action, nonNegatedSuffix) {
return function () {
assertCanWorkWith(this);
var alwaysSinonMethod = "always" + sinonName[0].toUpperCase() + sinonName.substring(1);
var shouldBeAlways = utils.flag(this, "always") && typeof this._obj[alwaysSinonMethod] === "function";
var sinonMethod = shouldBeAlways ? alwaysSinonMethod : sinonName;
var messages = getMessages(this._obj, action, nonNegatedSuffix, shouldBeAlways, slice.call(arguments));
this.assert(this._obj[sinonMethod].apply(this._obj, arguments), messages.affirmative, messages.negative);
};
}
function sinonMethodAsProperty(name, action, nonNegatedSuffix) {
var handler = createSinonMethodHandler(name, action, nonNegatedSuffix);
utils.addProperty(chai.Assertion.prototype, name, handler);
}
function exceptionalSinonMethod(chaiName, sinonName, action, nonNegatedSuffix) {
var handler = createSinonMethodHandler(sinonName, action, nonNegatedSuffix);
utils.addMethod(chai.Assertion.prototype, chaiName, handler);
}
function sinonMethod(name, action, nonNegatedSuffix) {
exceptionalSinonMethod(name, name, action, nonNegatedSuffix);
}
utils.addProperty(chai.Assertion.prototype, "always", function () {
utils.flag(this, "always", true);
});
sinonProperty("called", "been called", " at least once, but it was never called");
sinonProperty("calledOnce", "been called exactly once", ", but it was called %c%C");
sinonProperty("calledTwice", "been called exactly twice", ", but it was called %c%C");
sinonProperty("calledThrice", "been called exactly thrice", ", but it was called %c%C");
sinonMethodAsProperty("calledWithNew", "been called with new");
sinonMethod("calledBefore", "been called before %1");
sinonMethod("calledAfter", "been called after %1");
sinonMethod("calledOn", "been called with %1 as this", ", but it was called with %t instead");
sinonMethod("calledWith", "been called with arguments %*", "%C");
sinonMethod("calledWithExactly", "been called with exact arguments %*", "%C");
sinonMethod("returned", "returned %1");
exceptionalSinonMethod("thrown", "threw", "thrown %1");
}));

File diff suppressed because it is too large Load Diff