Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements the assertion event according to js-reporters standard
- Loading branch information
Showing
4 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>QUnit Events Test Suite</title> | ||
<link rel="stylesheet" href="../dist/qunit.css"> | ||
<script src="../dist/qunit.js"></script> | ||
<script src="events.js"></script> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* This test file verifies the execution order and contents of events emitted | ||
* by QUnit. They are expected to adhere to the js-reporters standard. | ||
*/ | ||
|
||
var invokedHooks = [], | ||
invokedHookDetails = {}, | ||
done = false; | ||
|
||
function callback( name ) { | ||
invokedHookDetails[ name ] = []; | ||
|
||
return function( details ) { | ||
if ( done ) { | ||
return; | ||
} | ||
|
||
invokedHooks.push( name ); | ||
invokedHookDetails[ name ].push( details ); | ||
}; | ||
} | ||
|
||
QUnit.on( "assertion", callback( "assertion1" ) ); | ||
QUnit.on( "assertion", callback( "assertion2" ) ); | ||
|
||
// After all the tests run, we verify the events were fired in the correct order | ||
// with the correct data | ||
QUnit.done( function() { | ||
if ( done ) { | ||
return; | ||
} | ||
|
||
done = true; | ||
|
||
QUnit.module( "Events" ); | ||
QUnit.test( "verify callback order and data", function( assert ) { | ||
assert.deepEqual( invokedHooks, [ | ||
"assertion1", | ||
"assertion2" | ||
], "event callbacks are called in correct order" ); | ||
|
||
assert.deepEqual( invokedHookDetails.assertion1[ 0 ], { | ||
passed: true, | ||
actual: true, | ||
expected: true, | ||
message: "passing assertion", | ||
stack: undefined | ||
}, "assertion callback data is correct" ); | ||
} ); | ||
} ); | ||
|
||
QUnit.module( "Events", function() { | ||
QUnit.test( "test1", function( assert ) { | ||
assert.ok( true, "passing assertion" ); | ||
} ); | ||
} ); |