[ADD] doc: new documentation, with training tutorials, and new scaffolding
[odoo/odoo.git] / doc / _themes / odoodoc / static / bootstrap / js / tests / unit / phantom.js
1 /*
2  * grunt-contrib-qunit
3  * http://gruntjs.com/
4  *
5  * Copyright (c) 2013 "Cowboy" Ben Alman, contributors
6  * Licensed under the MIT license.
7  */
8
9 (function () {
10   'use strict';
11
12   // Don't re-order tests.
13   QUnit.config.reorder = false
14   // Run tests serially, not in parallel.
15   QUnit.config.autorun = false
16
17   // Send messages to the parent PhantomJS process via alert! Good times!!
18   function sendMessage() {
19     var args = [].slice.call(arguments)
20     alert(JSON.stringify(args))
21   }
22
23   // These methods connect QUnit to PhantomJS.
24   QUnit.log = function (obj) {
25     // What is this I don’t even
26     if (obj.message === '[object Object], undefined:undefined') { return }
27     // Parse some stuff before sending it.
28     var actual = QUnit.jsDump.parse(obj.actual)
29     var expected = QUnit.jsDump.parse(obj.expected)
30     // Send it.
31     sendMessage('qunit.log', obj.result, actual, expected, obj.message, obj.source)
32   }
33
34   QUnit.testStart = function (obj) {
35     sendMessage('qunit.testStart', obj.name)
36   }
37
38   QUnit.testDone = function (obj) {
39     sendMessage('qunit.testDone', obj.name, obj.failed, obj.passed, obj.total)
40   }
41
42   QUnit.moduleStart = function (obj) {
43     sendMessage('qunit.moduleStart', obj.name)
44   }
45
46   QUnit.begin = function () {
47     sendMessage('qunit.begin')
48     console.log('Starting test suite')
49     console.log('================================================\n')
50   }
51
52   QUnit.moduleDone = function (opts) {
53     if (opts.failed === 0) {
54       console.log('\r\u2714 All tests passed in "' + opts.name + '" module')
55     } else {
56       console.log('\u2716 ' + opts.failed + ' tests failed in "' + opts.name + '" module')
57     }
58     sendMessage('qunit.moduleDone', opts.name, opts.failed, opts.passed, opts.total)
59   }
60
61   QUnit.done = function (opts) {
62     console.log('\n================================================')
63     console.log('Tests completed in ' + opts.runtime + ' milliseconds')
64     console.log(opts.passed + ' tests of ' + opts.total + ' passed, ' + opts.failed + ' failed.')
65     sendMessage('qunit.done', opts.failed, opts.passed, opts.total, opts.runtime)
66   }
67
68 }())