diff options
author | Alexander Lisianoi <all3fox@gmail.com> | 2016-03-05 10:48:52 +0100 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2016-03-09 14:09:20 -0500 |
commit | 59ec78e6020cc963c1f95cb96a28eaaf20e37b3e (patch) | |
tree | 3fe106c83cc9fd0afabbc78d6e4155d116a4a785 /test/data | |
parent | 474b477eed8643c7e4e62247918c705dd8c933e6 (diff) | |
download | jquery-59ec78e6020cc963c1f95cb96a28eaaf20e37b3e.tar.gz jquery-59ec78e6020cc963c1f95cb96a28eaaf20e37b3e.zip |
Tests: Restrict "p > * > *" selection in selector.js to #qunit-fixture
Add `match` and `QUnit.assert.selectInFixture` functions that
mimic `QUnit.assert.t`.
Ref gh-2880
Closes gh-2973
Diffstat (limited to 'test/data')
-rw-r--r-- | test/data/testinit.js | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js index ca8f433d7..073dc349f 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -32,14 +32,14 @@ this.q = function() { /** * Asserts that a select matches the given IDs - * @param {String} a - Assertion name - * @param {String} b - Sizzle selector - * @param {String} c - Array of ids to construct what is expected - * @example t("Check for something", "//[a]", ["foo", "bar"]); - * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'bar' + * @param {String} message - Assertion name + * @param {String} selector - Sizzle selector + * @param {String} expectedIds - Array of ids to construct what is expected + * @param {(String|Node)=document} context - Selector context + * @example match("Check for something", "p", ["foo", "bar"]); */ -QUnit.assert.t = function( a, b, c ) { - var f = jQuery( b ).get(), +function match( message, selector, expectedIds, context ) { + var f = jQuery( selector, context ).get(), s = "", i = 0; @@ -47,7 +47,31 @@ QUnit.assert.t = function( a, b, c ) { s += ( s && "," ) + '"' + f[ i ].id + '"'; } - this.deepEqual( f, q.apply( q, c ), a + " (" + b + ")" ); + this.deepEqual( f, q.apply( q, expectedIds ), message + " (" + selector + ")" ); +} + +/** + * Asserts that a select matches the given IDs. + * The select is not bound by a context. + * @param {String} message - Assertion name + * @param {String} selector - Sizzle selector + * @param {String} expectedIds - Array of ids to construct what is expected + * @example t("Check for something", "p", ["foo", "bar"]); + */ +QUnit.assert.t = function( message, selector, expectedIds ) { + match( message, selector, expectedIds, undefined ); +}; + +/** + * Asserts that a select matches the given IDs. + * The select is performed within the `#qunit-fixture` context. + * @param {String} message - Assertion name + * @param {String} selector - Sizzle selector + * @param {String} expectedIds - Array of ids to construct what is expected + * @example selectInFixture("Check for something", "p", ["foo", "bar"]); + */ +QUnit.assert.selectInFixture = function( message, selector, expectedIds ) { + match( message, selector, expectedIds, "#qunit-fixture" ); }; this.createDashboardXML = function() { |