Skip to content

Commit

Permalink
Update README to stylize docs on jQuery's test suite methods
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed May 29, 2012
1 parent a8d9d05 commit 5660b6d
Showing 1 changed file with 64 additions and 45 deletions.
109 changes: 64 additions & 45 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -164,56 +164,75 @@ Following are some commands that can be used there:
[QUnit](http://docs.jquery.com/QUnit) Reference [QUnit](http://docs.jquery.com/QUnit) Reference
----------------- -----------------


Test methods: ### Test methods ###
expect( numAssertions )
stop() expect( numAssertions );
start() stop();
start();
note: QUnit's eventual addition of an argument to stop/start is ignored in this test suite note: QUnit's eventual addition of an argument to stop/start is ignored in this test suite
so that start and stop can be passed as callbacks without worrying about so that start and stop can be passed as callbacks without worrying about their parameters
their parameters

### Test assertions ###
Test assertions:
ok( value, [message] ) ok( value, [message] );
equal( actual, expected, [message] ) equal( actual, expected, [message] );
notEqual( actual, expected, [message] ) notEqual( actual, expected, [message] );
deepEqual( actual, expected, [message] ) deepEqual( actual, expected, [message] );
notDeepEqual( actual, expected, [message] ) notDeepEqual( actual, expected, [message] );
strictEqual( actual, expected, [message] ) strictEqual( actual, expected, [message] );
notStrictEqual( actual, expected, [message] ) notStrictEqual( actual, expected, [message] );
raises( block, [expected], [message] ) raises( block, [expected], [message] );


Test Suite Convenience Methods Reference (See [test/data/testinit.js](https://github.com/jquery/jquery/blob/master/test/data/testinit.js)) Test Suite Convenience Methods Reference (See [test/data/testinit.js](https://github.com/jquery/jquery/blob/master/test/data/testinit.js))
------------------------------ ------------------------------


q( ... ); ### Returns an array of elements with the given IDs ###
Returns an array of elements with the given IDs
@example q("main", "foo", "bar") => [<div id="main">, <span id="foo">, <input id="bar">] q( ... );


t( testName, selector, [ "#array", "#of", "#ids" ] ); @example `q("main", "foo", "bar")` => [`<div id="main">`, `<span id="foo">`, `input id="bar">`]
Asserts that a select matches the given IDs
@example t("Check for something", "//[a]", ["foo", "baar"]); ### Asserts that a select matches the given IDs ###


fireNative( node, eventType ); t( testName, selector, [ "#array", "#of", "#ids" ] );
Fires a native DOM event without going through jQuery
@example fireNative( jQuery("#elem")[0], "click" ); @example `t("Check for something", "//[a]", ["foo", "baar"]);`


url( "some/url.php" ); ### Fires a native DOM event without going through jQuery ###
Add random number to url to stop caching
@example url("data/test.html") => "data/test.html?10538358428943" fireNative( node, eventType );
@example url("data/test.php?foo=bar") => "data/test.php?foo=bar&10538358345554"

@example `fireNative( jQuery("#elem")[0], "click" );`
testIframe( fileName, testName, callback );
Loads a given page constructing a url with fileName: "./data/" + fileName + ".html" ### Add random number to url to stop caching ###
and fires the given callback on jQuery ready (using the jQuery loading from that page)
and passes the iFrame's jQuery to the callback. url( "some/url.php" );
Callback arguments:
callback( jQueryFromIFrame, iFrameWindow, iFrameDocument ) @example `url("data/test.html")` => `"data/test.html?10538358428943"`


testIframeWithCallback( testName, fileName, callback ) @example `url("data/test.php?foo=bar")` => `"data/test.php?foo=bar&10538358345554"`
Loads a given page constructing a url with fileName: "./data/" + fileName + ".html"
The given callback is fired when window.iframeCallback is called by the page
The arguments passed to the callback are the same as the ### Load tests in an iframe ###
arguments passed to window.iframeCallback, whatever that may be
Loads a given page constructing a url with fileName: `"./data/" + fileName + ".html"`
and fires the given callback on jQuery ready (using the jQuery loading from that page)
and passes the iFrame's jQuery to the callback.

testIframe( fileName, testName, callback );

Callback arguments:

callback( jQueryFromIFrame, iFrameWindow, iFrameDocument )

### Load tests in an iframe (window.iframeCallback) ###

Loads a given page constructing a url with fileName: `"./data/" + fileName + ".html"`
The given callback is fired when window.iframeCallback is called by the page
The arguments passed to the callback are the same as the
arguments passed to window.iframeCallback, whatever that may be

testIframeWithCallback( testName, fileName, callback )


Questions? Questions?
---------- ----------
Expand Down

0 comments on commit 5660b6d

Please sign in to comment.