aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorJohn-Philip Johansson <[email protected]>2013-05-04 16:55:52 +0200
committerChris Rebert <[email protected]>2013-07-26 00:39:14 -0700
commit0d33455ef486d0cf06cb29d427efda57f42f7ea9 (patch)
treef7ddc320adff7ed7bed55b90665bb1dad3e8e01e /js/tests
parent995add132efdb6557f191f1a65097f19260a4f7d (diff)
downloadbootstrap-0d33455ef486d0cf06cb29d427efda57f42f7ea9.tar.xz
bootstrap-0d33455ef486d0cf06cb29d427efda57f42f7ea9.zip
Replace Makefile with GruntJS
A rebase (against soon-to-be 3.0.0-rc.1) & squash of https://github.com/twbs/bootstrap/pull/7786 AKA https://github.com/twitter/bootstrap/pull/7786 originally by @seriema @mokkabonna @jojohess Rebased by @cvrebert
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/index.html3
-rw-r--r--js/tests/unit/button.js15
-rw-r--r--js/tests/unit/phantom.js90
3 files changed, 77 insertions, 31 deletions
diff --git a/js/tests/index.html b/js/tests/index.html
index 0cfadc598..501bf38f2 100644
--- a/js/tests/index.html
+++ b/js/tests/index.html
@@ -11,9 +11,6 @@
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" />
<script src="vendor/qunit.js"></script>
- <!-- phantomjs logging script-->
- <script src="unit/phantom.js"></script>
-
<!-- plugin sources -->
<script src="../../js/transition.js"></script>
<script src="../../js/alert.js"></script>
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js
index 0f8988a7d..41ddb5c2f 100644
--- a/js/tests/unit/button.js
+++ b/js/tests/unit/button.js
@@ -40,14 +40,15 @@ $(function () {
ok(btn.hasClass('disabled'), 'btn has disabled class')
start()
stop()
+ btn.button('reset')
+ equals(btn.html(), 'mdo', 'btn text equals mdo')
+ setTimeout(function () {
+ ok(!btn.attr('disabled'), 'btn is not disabled')
+ ok(!btn.hasClass('disabled'), 'btn does not have disabled class')
+ start()
+ }, 0)
}, 0)
- btn.button('reset')
- equals(btn.html(), 'mdo', 'btn text equals mdo')
- setTimeout(function () {
- ok(!btn.attr('disabled'), 'btn is not disabled')
- ok(!btn.hasClass('disabled'), 'btn does not have disabled class')
- start()
- }, 0)
+
})
test("should toggle active", function () {
diff --git a/js/tests/unit/phantom.js b/js/tests/unit/phantom.js
index c01e71c15..c584c5a35 100644
--- a/js/tests/unit/phantom.js
+++ b/js/tests/unit/phantom.js
@@ -1,21 +1,69 @@
-// Logging setup for phantom integration
-// adapted from Modernizr
-
-QUnit.begin = function () {
- console.log("Starting test suite")
- console.log("================================================\n")
-}
-
-QUnit.moduleDone = function (opts) {
- if (opts.failed === 0) {
- console.log("\u2714 All tests passed in '" + opts.name + "' module")
- } else {
- console.log("\u2716 " + opts.failed + " tests failed in '" + opts.name + "' module")
- }
-}
-
-QUnit.done = function (opts) {
- console.log("\n================================================")
- console.log("Tests completed in " + opts.runtime + " milliseconds")
- console.log(opts.passed + " tests of " + opts.total + " passed, " + opts.failed + " failed.")
-}
+/*
+ * grunt-contrib-qunit
+ * http://gruntjs.com/
+ *
+ * Copyright (c) 2013 "Cowboy" Ben Alman, contributors
+ * Licensed under the MIT license.
+ */
+
+/*global QUnit:true, alert:true*/
+(function () {
+ 'use strict';
+
+ // Don't re-order tests.
+ QUnit.config.reorder = false
+ // Run tests serially, not in parallel.
+ QUnit.config.autorun = false
+
+ // Send messages to the parent PhantomJS process via alert! Good times!!
+ function sendMessage() {
+ var args = [].slice.call(arguments)
+ alert(JSON.stringify(args))
+ }
+
+ // These methods connect QUnit to PhantomJS.
+ QUnit.log = function(obj) {
+ // What is this I don’t even
+ if (obj.message === '[object Object], undefined:undefined') { return }
+ // Parse some stuff before sending it.
+ var actual = QUnit.jsDump.parse(obj.actual)
+ var expected = QUnit.jsDump.parse(obj.expected)
+ // Send it.
+ sendMessage('qunit.log', obj.result, actual, expected, obj.message, obj.source)
+ }
+
+ QUnit.testStart = function(obj) {
+ sendMessage('qunit.testStart', obj.name)
+ }
+
+ QUnit.testDone = function(obj) {
+ sendMessage('qunit.testDone', obj.name, obj.failed, obj.passed, obj.total)
+ }
+
+ QUnit.moduleStart = function(obj) {
+ sendMessage('qunit.moduleStart', obj.name)
+ }
+
+ QUnit.begin = function () {
+ sendMessage('qunit.begin')
+ console.log("Starting test suite")
+ console.log("================================================\n")
+ }
+
+ QUnit.moduleDone = function (opts) {
+ if (opts.failed === 0) {
+ console.log("\r\u2714 All tests passed in '" + opts.name + "' module")
+ } else {
+ console.log("\u2716 " + opts.failed + " tests failed in '" + opts.name + "' module")
+ }
+ sendMessage('qunit.moduleDone', opts.name, opts.failed, opts.passed, opts.total)
+ }
+
+ QUnit.done = function (opts) {
+ console.log("\n================================================")
+ console.log("Tests completed in " + opts.runtime + " milliseconds")
+ console.log(opts.passed + " tests of " + opts.total + " passed, " + opts.failed + " failed.")
+ sendMessage('qunit.done', opts.failed, opts.passed, opts.total, opts.runtime)
+ }
+
+}())