Home page Forum Wiki Mail Jabber Devel NIX-FILES

AltLUG Git

Git-repositories of Altai Linux User Group

232cabeeb4a688e6caf3755f2976d6f89718a04c
[qunit.git] / addons / composite / qunit-composite.js
1 (function( QUnit ) {
2
3 QUnit.extend( QUnit, {
4         testSuites: function( suites ) {
5                 QUnit.initIframe();
6
7                 for ( var i = 0; i < suites.length; i++ ) {
8                         (function( suite ) {
9                                 asyncTest( suite, function() {
10                                         QUnit.runSuite( suite );
11                                 });
12                         }( suites[i] ) );
13                 }
14                 QUnit.done = function() {
15                         this.iframe.style.display = "none";
16                 };
17         },
18
19         testStart: function( data ) {
20                 // update the test status to show which test suite is running
21                 QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br>&nbsp;";
22         },
23
24         testDone: function() {
25                 var current = QUnit.id( this.config.current.id ),
26                         children = current.children,
27                         iframe = this.iframe;
28
29                 // undo the auto-expansion of failed tests
30                 for ( var i = 0; i < children.length; i++ ) {
31                         if ( children[i].nodeName === "OL" ) {
32                                 children[i].style.display = "none";
33                         }
34                 }
35
36                 QUnit.addEvent(current, "dblclick", function( e ) {
37                         var target = e && e.target ? e.target : window.event.srcElement;
38                         if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
39                                 target = target.parentNode;
40                         }
41                         if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
42                                 window.location = iframe.src;
43                         }
44                 });
45
46                 current.getElementsByTagName('a')[0].href = iframe.src;
47         },
48
49         runSuite: function( suite ) {
50                 this.iframe.setAttribute( "src", suite );
51         },
52
53         initIframe: function() {
54                 var body = document.body,
55                         iframe = this.iframe = document.createElement( "iframe" ),
56                         iframeWin;
57
58                 iframe.className = "qunit-subsuite";
59                 body.appendChild( iframe );
60
61                 function onIframeLoad() {
62                         var module, test,
63                                 count = 0;
64
65                         QUnit.extend( iframeWin.QUnit, {
66                                 moduleStart: function( data ) {
67                                         // capture module name for messages
68                                         module = data.name;
69                                 },
70
71                                 testStart: function( data ) {
72                                         // capture test name for messages
73                                         test = data.name;
74                                 },
75
76                                 log: function( data ) {
77                                         // pass all test details through to the main page
78                                         var message = module + ": " + test + ": " + data.message;
79                                         expect( ++count );
80                                         QUnit.push( data.result, data.actual, data.expected, message );
81                                 },
82
83                                 done: function() {
84                                         // start the wrapper test from the main page
85                                         start();
86                                 }
87                         });
88                 }
89                 QUnit.addEvent( iframe, "load", onIframeLoad );
90
91                 iframeWin = iframe.contentWindow;
92         }
93 });
94 }( QUnit ) );

Hosting is provided AltSPAHow to use Git
Please direct any questions on jabber alex.wolf@jabber.ru

Valid HTML 4.0 Transitional Valid CSS!

Designer Alexander Wolf