Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

1.0.0 cleanup, add Makefile

  • Loading branch information...
commit a9cd0179f92addbada229f19e8bdc98d74deb9d5 1 parent 731c236
@cjohansen authored
View
3  Changelog.txt
@@ -1,2 +1,5 @@
== 1.0.0 / 2010-12-06
+* Hooked assertions into QUnit's assertion counter
+* Added documentation
+== 0.1.0 / 2010-10-31
* Initial release
View
10 Makefile
@@ -0,0 +1,10 @@
+default: test lint build
+build:
+ ./build
+test: lib/sinon-qunit.js
+ jstestdriver --tests all --reset
+clean:
+ rm -fr pkg
+lint:
+ juicer verify {lib,test}/*.js
+ jsl --conf jsl.conf lib/*.js test/*.js
View
30 build
@@ -4,7 +4,6 @@ require "pathname"
def add_license(file, version)
contents = File.read(file)
- copyright = Time.now.year == 2010 ? "2010" : "2010-#{Time.now.year}"
File.open(file, "w") do |f|
f.puts <<PREAMBLE
@@ -13,34 +12,7 @@ def add_license(file, version)
*
* @author Christian Johansen (christian@cjohansen.no)
*
- * (The BSD License)
- *
- * Copyright (c) #{copyright}, Christian Johansen, christian@cjohansen.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:
- *
- * * 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.
- *
+ * #{File.read("LICENSE").split("\n").join("\n * ")}
*/
PREAMBLE
View
11 jsTestDriver.conf
@@ -4,14 +4,9 @@ load:
- deps/sinon/lib/sinon.js
- deps/sinon/lib/sinon/spy.js
- deps/sinon/lib/sinon/stub.js
- - deps/sinon/lib/sinon/collection.js
- - deps/sinon/lib/sinon/*.js
- - deps/sinon/lib/sinon/util/fake_timers.js
- - deps/sinon/lib/sinon/util/fake_xml_http_request.js
- - deps/sinon/lib/sinon/util/timers_ie.js
- - deps/sinon/lib/sinon/util/xhr_ie.js
- - deps/sinon/lib/sinon/util/*.js
- - test/plugin-setup.js
+ - deps/sinon/lib/sinon/assert.js
+ - deps/sinon/lib/sinon/test.js
+ - test/fake_qunit.js
- lib/*.js
- test/helper.js
- test/*.js
View
8 jsl.conf
@@ -0,0 +1,8 @@
++output-format __FILENAME__(__LINE__): __ERROR__
+
++define sinon
++define QUnit
++define testCase
++define test
++define assert
++define TestCase
View
37 lib/sinon-qunit.js
@@ -1,30 +1,29 @@
-/*jslint indent: 2*/
/*global sinon, QUnit, test*/
sinon.assert.fail = function (msg) {
- QUnit.ok(false, msg);
+ QUnit.ok(false, msg);
};
sinon.assert.pass = function (assertion) {
- QUnit.ok(true, assertion);
+ QUnit.ok(true, assertion);
};
sinon.config = {
- injectIntoThis: true,
- injectInto: null,
- properties: ["spy", "stub", "mock", "clock", "sandbox"],
- useFakeTimers: true,
- useFakeServer: false
+ injectIntoThis: true,
+ injectInto: null,
+ properties: ["spy", "stub", "mock", "clock", "sandbox"],
+ useFakeTimers: true,
+ useFakeServer: false
};
-(function () {
- var qTest = QUnit.test;
+(function (global) {
+ var qTest = QUnit.test;
+
+ QUnit.test = global.test = function (testName, expected, callback, async) {
+ if (arguments.length === 2) {
+ callback = expected;
+ expected = null;
+ }
- QUnit.test = test = function (testName, expected, callback, async) {
- if (arguments.length === 2) {
- callback = expected;
- expected = null;
- }
-
- return qTest(testName, expected, sinon.test(callback), async);
- };
-}());
+ return qTest(testName, expected, sinon.test(callback), async);
+ };
+}(this));
View
50 pkg/sinon-qunit-1.0.0.js
@@ -1,16 +1,16 @@
/**
- * Sinon.JS 1.0.0, 2010/12/06
+ * sinon-qunit 1.0.0, 2010/12/08
*
* @author Christian Johansen (christian@cjohansen.no)
*
* (The BSD License)
- *
- * Copyright (c) 2010, Christian Johansen, christian@cjohansen.no
+ *
+ * Copyright (c) 2010-2011, Christian Johansen, christian@cjohansen.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:
- *
+ *
* * 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,
@@ -19,7 +19,7 @@
* * 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
@@ -30,35 +30,33 @@
* 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.
- *
*/
-/*jslint indent: 2*/
/*global sinon, QUnit, test*/
sinon.assert.fail = function (msg) {
- QUnit.ok(false, msg);
+ QUnit.ok(false, msg);
};
sinon.assert.pass = function (assertion) {
- QUnit.ok(true, assertion);
+ QUnit.ok(true, assertion);
};
sinon.config = {
- injectIntoThis: true,
- injectInto: null,
- properties: ["spy", "stub", "mock", "clock", "sandbox"],
- useFakeTimers: true,
- useFakeServer: false
+ injectIntoThis: true,
+ injectInto: null,
+ properties: ["spy", "stub", "mock", "clock", "sandbox"],
+ useFakeTimers: true,
+ useFakeServer: false
};
-(function () {
- var qTest = QUnit.test;
-
- QUnit.test = test = function (testName, expected, callback, async) {
- if (arguments.length === 2) {
- callback = expected;
- expected = null;
- }
+(function (global) {
+ var qTest = QUnit.test;
+
+ QUnit.test = global.test = function (testName, expected, callback, async) {
+ if (arguments.length === 2) {
+ callback = expected;
+ expected = null;
+ }
- return qTest(testName, expected, sinon.test(callback), async);
- };
-}());
+ return qTest(testName, expected, sinon.test(callback), async);
+ };
+}(this));
View
7 test/fake_qunit.js
@@ -0,0 +1,7 @@
+/*global sinon*/
+var QUnit = {
+ ok: function () {},
+ test: sinon.spy()
+};
+
+QUnit.originalTest = QUnit.test;
View
26 test/helper.js
@@ -1,4 +1,4 @@
-/*jslint indent: 2, onevar: false, eqeqeq: false*/
+/*jslint onevar: false, eqeqeq: false*/
/*global TestCase*/
/**
* @author Christian Johansen (christian@cjohansen.no)
@@ -7,19 +7,19 @@
* Copyright (c) 2010 Christian Johansen
*/
function testCase(name, tests) {
- var jstdCase = {};
- var jstdTestCase = TestCase; // Silence JsLint...
+ var jstdCase = {};
+ var jstdTestCase = TestCase; // Silence JsLint...
- for (var prop in tests) {
- if (tests.hasOwnProperty(prop)) {
- if (!/(^(setUp|tearDown)$)|^test/.test(prop) &&
- typeof tests[prop] == "function") {
- jstdCase["test " + prop] = tests[prop];
- } else {
- jstdCase[prop] = tests[prop];
- }
+ for (var prop in tests) {
+ if (tests.hasOwnProperty(prop)) {
+ if (!/(^(setUp|tearDown)$)|^test/.test(prop) &&
+ typeof tests[prop] == "function") {
+ jstdCase["test " + prop] = tests[prop];
+ } else {
+ jstdCase[prop] = tests[prop];
+ }
+ }
}
- }
- jstdTestCase(name, jstdCase);
+ jstdTestCase(name, jstdCase);
}
View
6 test/plugin-setup.js
@@ -1,6 +0,0 @@
-var QUnit = {
- ok: function () {},
- test: sinon.spy()
-};
-
-QUnit.originalTest = QUnit.test;
View
158 test/sinon-qunit-test.js
@@ -1,81 +1,83 @@
+/*jslint onevar: false*/
+/*global testCase, QUnit, assert, sinon, test*/
testCase("SinonQUnitTest", {
- setUp: function () {
- sinon.spy(QUnit, "ok");
- },
-
- tearDown: function () {
- if (sinon.test.restore) {
- sinon.test.restore();
+ setUp: function () {
+ sinon.spy(QUnit, "ok");
+ },
+
+ tearDown: function () {
+ if (sinon.test.restore) {
+ sinon.test.restore();
+ }
+
+ QUnit.originalTest.callCount = 0;
+ QUnit.originalTest.args = [];
+ QUnit.ok.restore();
+ },
+
+ "should fail through ok": function () {
+ sinon.assert.fail("Uh-oh!");
+
+ assert(QUnit.ok.calledOnce);
+ assert(QUnit.ok.calledWithExactly(false, "Uh-oh!"));
+ },
+
+ "should pass through ok": function () {
+ sinon.assert.pass("calledOnce");
+
+ assert(QUnit.ok.calledOnce);
+ assert(QUnit.ok.calledWithExactly(true, "calledOnce"));
+ },
+
+ "should pass callback to sinon.test": function () {
+ sinon.spy(sinon, "test");
+ var func = function () {};
+ test("Test", func);
+
+ assert(sinon.test.calledOnce);
+ assert(sinon.test.calledWith(func));
+ },
+
+ "should pass name and sandboxed callback to QUnit": function () {
+ var sandboxed = function () {};
+ sinon.stub(sinon, "test").returns(sandboxed);
+ QUnit.test("Test", function () {});
+
+ assert(QUnit.originalTest.calledOnce);
+ assert(QUnit.originalTest.calledWith("Test", null, sandboxed, undefined));
+ },
+
+ "should pass name, expected and sandboxed callback to QUnit": function () {
+ var sandboxed = function () {};
+ sinon.stub(sinon, "test").returns(sandboxed);
+ QUnit.test("Test This", 23, function () {});
+
+ assert(QUnit.originalTest.calledWith("Test This", 23, sandboxed, undefined));
+ },
+
+ "should pass name, env and sandboxed callback to QUnit": function () {
+ var sandboxed = function () {};
+ var env = { id: 42 };
+ sinon.stub(sinon, "test").returns(sandboxed);
+ QUnit.test("Test This", env, function () {});
+
+ assert(QUnit.originalTest.calledWith("Test This", env, sandboxed, undefined));
+ },
+
+ "should pass name, env, sandboxed callback and async to QUnit": function () {
+ var sandboxed = function () {};
+ var env = { id: 42 };
+ sinon.stub(sinon, "test").returns(sandboxed);
+ QUnit.test("Test This", env, function () {}, true);
+
+ assert(QUnit.originalTest.calledWith("Test This", env, sandboxed, true));
+ },
+
+ "should pass name, expected, sandboxed callback and async to QUnit": function () {
+ var sandboxed = function () {};
+ sinon.stub(sinon, "test").returns(sandboxed);
+ QUnit.test("Test This", 42, function () {}, true);
+
+ assert(QUnit.originalTest.calledWith("Test This", 42, sandboxed, true));
}
-
- QUnit.originalTest.callCount = 0;
- QUnit.originalTest.args = [];
- QUnit.ok.restore();
- },
-
- "should fail through ok": function () {
- sinon.assert.fail("Uh-oh!");
-
- assert(QUnit.ok.calledOnce);
- assert(QUnit.ok.calledWithExactly(false, "Uh-oh!"));
- },
-
- "should pass through ok": function () {
- sinon.assert.pass("calledOnce");
-
- assert(QUnit.ok.calledOnce);
- assert(QUnit.ok.calledWithExactly(true, "calledOnce"));
- },
-
- "should pass callback to sinon.test": function () {
- sinon.spy(sinon, "test");
- var func = function () {};
- test("Test", func);
-
- assert(sinon.test.calledOnce);
- assert(sinon.test.calledWith(func));
- },
-
- "should pass name and sandboxed callback to QUnit": function () {
- var sandboxed = function () {};
- sinon.stub(sinon, "test").returns(sandboxed);
- QUnit.test("Test", function () {});
-
- assert(QUnit.originalTest.calledOnce);
- assert(QUnit.originalTest.calledWith("Test", null, sandboxed, undefined));
- },
-
- "should pass name, expected and sandboxed callback to QUnit": function () {
- var sandboxed = function () {};
- sinon.stub(sinon, "test").returns(sandboxed);
- QUnit.test("Test This", 23, function () {});
-
- assert(QUnit.originalTest.calledWith("Test This", 23, sandboxed, undefined));
- },
-
- "should pass name, env and sandboxed callback to QUnit": function () {
- var sandboxed = function () {};
- var env = { id: 42 };
- sinon.stub(sinon, "test").returns(sandboxed);
- QUnit.test("Test This", env, function () {});
-
- assert(QUnit.originalTest.calledWith("Test This", env, sandboxed, undefined));
- },
-
- "should pass name, env, sandboxed callback and async to QUnit": function () {
- var sandboxed = function () {};
- var env = { id: 42 };
- sinon.stub(sinon, "test").returns(sandboxed);
- QUnit.test("Test This", env, function () {}, true);
-
- assert(QUnit.originalTest.calledWith("Test This", env, sandboxed, true));
- },
-
- "should pass name, expected, sandboxed callback and async to QUnit": function () {
- var sandboxed = function () {};
- sinon.stub(sinon, "test").returns(sandboxed);
- QUnit.test("Test This", 42, function () {}, true);
-
- assert(QUnit.originalTest.calledWith("Test This", 42, sandboxed, true));
- }
});
Please sign in to comment.
Something went wrong with that request. Please try again.