Build/Test Tools: Update QUnit and Sinon to the latest versions.
Update JS tests per the QUnit 2.x Upgrade Guide. Fixes #37117. git-svn-id: https://develop.svn.wordpress.org/trunk@47512 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
bef2746334
commit
98584d6e11
406
package-lock.json
generated
406
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -63,6 +63,9 @@
|
||||
"jquery-migrate": "1.4.1",
|
||||
"matchdep": "~2.0.0",
|
||||
"node-sass": "~4.13.1",
|
||||
"qunit": "~2.9.0",
|
||||
"sinon": "~9.0.0",
|
||||
"sinon-test": "~3.0.0",
|
||||
"source-map-loader": "^0.2.4",
|
||||
"uglify-js": "^3.6.0",
|
||||
"uglifyjs-webpack-plugin": "2.2.0",
|
||||
|
@ -56,11 +56,19 @@
|
||||
<script src="../../build/wp-includes/js/mce-view.js"></script>
|
||||
|
||||
<!-- QUnit -->
|
||||
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" />
|
||||
<script src="vendor/qunit.js"></script>
|
||||
<script src="vendor/sinon.js"></script>
|
||||
<script src="vendor/sinon-qunit.js"></script>
|
||||
<script>QUnit.config.hidepassed = false;</script>
|
||||
<link rel="stylesheet" href="../../node_modules/qunit/qunit/qunit.css" type="text/css" media="screen" />
|
||||
<script src="../../node_modules/qunit/qunit/qunit.js"></script>
|
||||
<script src="../../node_modules/sinon/pkg/sinon.js"></script>
|
||||
<script src="../../node_modules/sinon-test/dist/sinon-test.js"></script>
|
||||
<script>
|
||||
var qTest = QUnit.test, sTest = sinonTest( sinon );
|
||||
|
||||
QUnit.config.hidepassed = false;
|
||||
|
||||
QUnit.test = function( testName, callback ) {
|
||||
return qTest( testName, sTest(callback) );
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
|
291
tests/qunit/vendor/qunit.css
vendored
291
tests/qunit/vendor/qunit.css
vendored
@ -1,291 +0,0 @@
|
||||
/*!
|
||||
* QUnit 1.18.0
|
||||
* http://qunitjs.com/
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* Date: 2015-04-03T10:23Z
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699A4;
|
||||
background-color: #0D3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: 400;
|
||||
|
||||
border-radius: 5px 5px 0 0;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #C2CCD1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar label {
|
||||
display: inline-block;
|
||||
padding: 0 0.5em 0 0.1em;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
color: #5E740B;
|
||||
background-color: #EEE;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
background-color: #2B81AF;
|
||||
color: #FFF;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-container {
|
||||
float: right;
|
||||
padding: 0.2em;
|
||||
}
|
||||
|
||||
.qunit-url-config {
|
||||
display: inline-block;
|
||||
padding: 0.1em;
|
||||
}
|
||||
|
||||
.qunit-filter {
|
||||
display: block;
|
||||
float: right;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 1em 0.4em 1em;
|
||||
border-bottom: 1px solid #FFF;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests > li {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li.running,
|
||||
#qunit-tests li.pass,
|
||||
#qunit-tests li.fail,
|
||||
#qunit-tests li.skipped {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.running,
|
||||
#qunit-tests.hidepass li.pass {
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li.skipped strong {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #C2CCD1;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests li p a {
|
||||
padding: 0.25em;
|
||||
color: #6B6464;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests li .runtime {
|
||||
float: right;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.qunit-assert-list {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #FFF;
|
||||
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.qunit-collapsed {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: 0.2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 0.5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #E0F2BE;
|
||||
color: #374E0C;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #FFCACA;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: #000; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
padding: 5px;
|
||||
background-color: #FFF;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #3C510C;
|
||||
background-color: #FFF;
|
||||
border-left: 10px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #FFF;
|
||||
border-left: 10px solid #EE5757;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 5px 5px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: #008000; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
/*** Skipped tests */
|
||||
|
||||
#qunit-tests .skipped {
|
||||
background-color: #EBECE9;
|
||||
}
|
||||
|
||||
#qunit-tests .qunit-skipped-label {
|
||||
background-color: #F4FF77;
|
||||
display: inline-block;
|
||||
font-style: normal;
|
||||
color: #366097;
|
||||
line-height: 1.8em;
|
||||
padding: 0 0.5em;
|
||||
margin: -0.4em 0.4em -0.4em 0;
|
||||
}
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
|
||||
color: #2B81AF;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid #FFF;
|
||||
}
|
||||
#qunit-testresult .module-name {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
}
|
3828
tests/qunit/vendor/qunit.js
vendored
3828
tests/qunit/vendor/qunit.js
vendored
File diff suppressed because it is too large
Load Diff
63
tests/qunit/vendor/sinon-qunit.js
vendored
63
tests/qunit/vendor/sinon-qunit.js
vendored
@ -1,63 +0,0 @@
|
||||
/**
|
||||
* sinon-qunit 1.0.0, 2010/12/09
|
||||
*
|
||||
* @author Christian Johansen (christian@cjohansen.no)
|
||||
*
|
||||
* (The BSD License)
|
||||
*
|
||||
* Copyright (c) 2010-2011, Christian Johansen, christian@cjohansen.no
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of Christian Johansen nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*global sinon, QUnit, test*/
|
||||
sinon.assert.fail = function (msg) {
|
||||
QUnit.ok(false, msg);
|
||||
};
|
||||
|
||||
sinon.assert.pass = function (assertion) {
|
||||
QUnit.ok(true, assertion);
|
||||
};
|
||||
|
||||
sinon.config = {
|
||||
injectIntoThis: true,
|
||||
injectInto: null,
|
||||
properties: ["spy", "stub", "mock", "clock", "sandbox"],
|
||||
useFakeTimers: true,
|
||||
useFakeServer: false
|
||||
};
|
||||
|
||||
(function (global) {
|
||||
var qTest = QUnit.test;
|
||||
|
||||
QUnit.test = global.test = function (testName, expected, callback, async) {
|
||||
if (arguments.length === 2) {
|
||||
callback = expected;
|
||||
expected = null;
|
||||
}
|
||||
|
||||
|
||||
return qTest(testName, expected, sinon.test(callback), async);
|
||||
};
|
||||
}(this));
|
4728
tests/qunit/vendor/sinon.js
vendored
4728
tests/qunit/vendor/sinon.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,14 @@
|
||||
/* global wp, test, ok, equal, module */
|
||||
/* global wp */
|
||||
|
||||
jQuery( function( $ ) {
|
||||
var FooSuperClass, BarSubClass, foo, bar, ConstructorTestClass, newConstructor, constructorTest, $mockElement, mockString,
|
||||
firstInitialValue, firstValueInstance, valuesInstance, wasCallbackFired, mockValueCallback;
|
||||
|
||||
module( 'Customize Base: Class' );
|
||||
QUnit.module( 'Customize Base: Class' );
|
||||
|
||||
FooSuperClass = wp.customize.Class.extend(
|
||||
{
|
||||
initialize: function ( instanceProps ) {
|
||||
initialize: function( instanceProps ) {
|
||||
$.extend( this, instanceProps || {} );
|
||||
},
|
||||
protoProp: 'protoPropValue'
|
||||
@ -17,40 +17,40 @@ jQuery( function( $ ) {
|
||||
staticProp: 'staticPropValue'
|
||||
}
|
||||
);
|
||||
test( 'FooSuperClass is a function ', function () {
|
||||
equal( typeof FooSuperClass, 'function' );
|
||||
QUnit.test( 'FooSuperClass is a function', function( assert ) {
|
||||
assert.equal( typeof FooSuperClass, 'function' );
|
||||
});
|
||||
test( 'FooSuperClass prototype has protoProp', function () {
|
||||
equal( FooSuperClass.prototype.protoProp, 'protoPropValue' );
|
||||
QUnit.test( 'FooSuperClass prototype has protoProp', function( assert ) {
|
||||
assert.equal( FooSuperClass.prototype.protoProp, 'protoPropValue' );
|
||||
});
|
||||
test( 'FooSuperClass does not have protoProp', function () {
|
||||
equal( typeof FooSuperClass.protoProp, 'undefined' );
|
||||
QUnit.test( 'FooSuperClass does not have protoProp', function( assert ) {
|
||||
assert.equal( typeof FooSuperClass.protoProp, 'undefined' );
|
||||
});
|
||||
test( 'FooSuperClass has staticProp', function () {
|
||||
equal( FooSuperClass.staticProp, 'staticPropValue' );
|
||||
QUnit.test( 'FooSuperClass has staticProp', function( assert ) {
|
||||
assert.equal( FooSuperClass.staticProp, 'staticPropValue' );
|
||||
});
|
||||
test( 'FooSuperClass prototype does not have staticProp', function () {
|
||||
equal( typeof FooSuperClass.prototype.staticProp, 'undefined' );
|
||||
QUnit.test( 'FooSuperClass prototype does not have staticProp', function( assert ) {
|
||||
assert.equal( typeof FooSuperClass.prototype.staticProp, 'undefined' );
|
||||
});
|
||||
|
||||
foo = new FooSuperClass( { instanceProp: 'instancePropValue' } );
|
||||
test( 'FooSuperClass instance foo extended Class', function () {
|
||||
equal( foo.extended( wp.customize.Class ), true );
|
||||
QUnit.test( 'FooSuperClass instance foo extended Class', function( assert ) {
|
||||
assert.equal( foo.extended( wp.customize.Class ), true );
|
||||
});
|
||||
test( 'foo instance has protoProp', function () {
|
||||
equal( foo.protoProp, 'protoPropValue' );
|
||||
QUnit.test( 'foo instance has protoProp', function( assert ) {
|
||||
assert.equal( foo.protoProp, 'protoPropValue' );
|
||||
});
|
||||
test( 'foo instance does not have staticProp', function () {
|
||||
equal( typeof foo.staticProp, 'undefined' );
|
||||
QUnit.test( 'foo instance does not have staticProp', function( assert ) {
|
||||
assert.equal( typeof foo.staticProp, 'undefined' );
|
||||
});
|
||||
test( 'FooSuperClass instance foo ran initialize() and has supplied instanceProp', function () {
|
||||
equal( foo.instanceProp, 'instancePropValue' );
|
||||
QUnit.test( 'FooSuperClass instance foo ran initialize() and has supplied instanceProp', function( assert ) {
|
||||
assert.equal( foo.instanceProp, 'instancePropValue' );
|
||||
});
|
||||
|
||||
// @todo Test Class.applicator?
|
||||
// @todo Do we test object.instance?
|
||||
|
||||
module( 'Customize Base: Subclass' );
|
||||
QUnit.module( 'Customize Base: Subclass' );
|
||||
|
||||
BarSubClass = FooSuperClass.extend(
|
||||
{
|
||||
@ -64,26 +64,26 @@ jQuery( function( $ ) {
|
||||
subStaticProp: 'subStaticPropValue'
|
||||
}
|
||||
);
|
||||
test( 'BarSubClass prototype has subProtoProp', function () {
|
||||
equal( BarSubClass.prototype.subProtoProp, 'subProtoPropValue' );
|
||||
QUnit.test( 'BarSubClass prototype has subProtoProp', function( assert ) {
|
||||
assert.equal( BarSubClass.prototype.subProtoProp, 'subProtoPropValue' );
|
||||
});
|
||||
test( 'BarSubClass prototype has parent FooSuperClass protoProp', function () {
|
||||
equal( BarSubClass.prototype.protoProp, 'protoPropValue' );
|
||||
QUnit.test( 'BarSubClass prototype has parent FooSuperClass protoProp', function( assert ) {
|
||||
assert.equal( BarSubClass.prototype.protoProp, 'protoPropValue' );
|
||||
});
|
||||
|
||||
bar = new BarSubClass( { instanceProp: 'instancePropValue' } );
|
||||
test( 'BarSubClass instance bar its initialize() and parent initialize() run', function () {
|
||||
equal( bar.instanceProp, 'instancePropValue' );
|
||||
equal( bar.subInstanceProp, 'subInstancePropValue' );
|
||||
QUnit.test( 'BarSubClass instance bar its initialize() and parent initialize() run', function( assert ) {
|
||||
assert.equal( bar.instanceProp, 'instancePropValue' );
|
||||
assert.equal( bar.subInstanceProp, 'subInstancePropValue' );
|
||||
});
|
||||
|
||||
test( 'BarSubClass instance bar extended FooSuperClass', function () {
|
||||
equal( bar.extended( FooSuperClass ), true );
|
||||
QUnit.test( 'BarSubClass instance bar extended FooSuperClass', function( assert ) {
|
||||
assert.equal( bar.extended( FooSuperClass ), true );
|
||||
});
|
||||
|
||||
|
||||
// Implements todo: Test Class.constructor() manipulation.
|
||||
module( 'Customize Base: Constructor Manipulation' );
|
||||
QUnit.module( 'Customize Base: Constructor Manipulation' );
|
||||
|
||||
newConstructor = function ( instanceProps ) {
|
||||
$.extend( this , instanceProps || {} );
|
||||
@ -99,71 +99,71 @@ jQuery( function( $ ) {
|
||||
}
|
||||
);
|
||||
|
||||
test( 'New constructor added to class' , function () {
|
||||
equal( ConstructorTestClass.prototype.constructor , newConstructor );
|
||||
QUnit.test( 'New constructor added to class', function( assert ) {
|
||||
assert.equal( ConstructorTestClass.prototype.constructor , newConstructor );
|
||||
});
|
||||
test( 'Class with new constructor has protoPropValue' , function () {
|
||||
equal( ConstructorTestClass.prototype.protoProp , 'protoPropValue' );
|
||||
QUnit.test( 'Class with new constructor has protoPropValue', function( assert ) {
|
||||
assert.equal( ConstructorTestClass.prototype.protoProp , 'protoPropValue' );
|
||||
});
|
||||
|
||||
constructorTest = new ConstructorTestClass( { instanceProp: 'instancePropValue' } );
|
||||
test( 'ConstructorTestClass instance constructorTest has the new constructor', function () {
|
||||
equal( constructorTest.constructor, newConstructor );
|
||||
QUnit.test( 'ConstructorTestClass instance constructorTest has the new constructor', function( assert ) {
|
||||
assert.equal( constructorTest.constructor, newConstructor );
|
||||
});
|
||||
|
||||
test( 'ConstructorTestClass instance constructorTest extended Class', function () {
|
||||
equal( constructorTest.extended( wp.customize.Class ), true );
|
||||
QUnit.test( 'ConstructorTestClass instance constructorTest extended Class', function( assert ) {
|
||||
assert.equal( constructorTest.extended( wp.customize.Class ), true );
|
||||
});
|
||||
|
||||
test( 'ConstructorTestClass instance constructorTest has the added instance property', function () {
|
||||
equal( constructorTest.instanceProp , 'instancePropValue' );
|
||||
QUnit.test( 'ConstructorTestClass instance constructorTest has the added instance property', function( assert ) {
|
||||
assert.equal( constructorTest.instanceProp , 'instancePropValue' );
|
||||
});
|
||||
|
||||
|
||||
module( 'Customize Base: wp.customizer.ensure' );
|
||||
QUnit.module( 'Customize Base: wp.customizer.ensure' );
|
||||
|
||||
$mockElement = $( '<div id="mockElement"></div>' );
|
||||
|
||||
test( 'Handles jQuery argument' , function() {
|
||||
equal( wp.customize.ensure( $mockElement ) , $mockElement );
|
||||
QUnit.test( 'Handles jQuery argument', function( assert ) {
|
||||
assert.equal( wp.customize.ensure( $mockElement ) , $mockElement );
|
||||
});
|
||||
|
||||
mockString = '<div class="mockString"></div>';
|
||||
|
||||
test( 'Handles string argument' , function() {
|
||||
ok( wp.customize.ensure( mockString ) instanceof jQuery );
|
||||
QUnit.test( 'Handles string argument', function( assert ) {
|
||||
assert.ok( wp.customize.ensure( mockString ) instanceof jQuery );
|
||||
});
|
||||
|
||||
|
||||
module( 'Customize Base: Value Class' );
|
||||
QUnit.module( 'Customize Base: Value Class' );
|
||||
|
||||
firstInitialValue = true;
|
||||
firstValueInstance = new wp.customize.Value( firstInitialValue );
|
||||
|
||||
test( 'Initialized with the right value' , function() {
|
||||
equal( firstValueInstance.get() , firstInitialValue );
|
||||
QUnit.test( 'Initialized with the right value', function( assert ) {
|
||||
assert.equal( firstValueInstance.get() , firstInitialValue );
|
||||
});
|
||||
|
||||
test( '.set() works' , function() {
|
||||
QUnit.test( '.set() works', function( assert ) {
|
||||
firstValueInstance.set( false );
|
||||
equal( firstValueInstance.get() , false );
|
||||
assert.equal( firstValueInstance.get() , false );
|
||||
});
|
||||
|
||||
test( '.bind() adds new callback that fires on set()' , function() {
|
||||
QUnit.test( '.bind() adds new callback that fires on set()', function( assert ) {
|
||||
wasCallbackFired = false;
|
||||
mockValueCallback = function() {
|
||||
wasCallbackFired = true;
|
||||
};
|
||||
firstValueInstance.bind( mockValueCallback );
|
||||
firstValueInstance.set( 'newValue' );
|
||||
ok( wasCallbackFired );
|
||||
assert.ok( wasCallbackFired );
|
||||
});
|
||||
|
||||
module( 'Customize Base: Values Class' );
|
||||
QUnit.module( 'Customize Base: Values Class' );
|
||||
|
||||
valuesInstance = new wp.customize.Values();
|
||||
|
||||
test( 'Correct events are triggered when adding to or removing from Values collection', function() {
|
||||
QUnit.test( 'Correct events are triggered when adding to or removing from Values collection', function( assert ) {
|
||||
var hasFooOnAdd = false,
|
||||
hasFooOnRemove = false,
|
||||
hasFooOnRemoved = true,
|
||||
@ -179,8 +179,8 @@ jQuery( function( $ ) {
|
||||
valuePassedToAdd = value;
|
||||
} );
|
||||
valuesInstance.add( 'foo', fooValue );
|
||||
ok( hasFooOnAdd );
|
||||
equal( valuePassedToAdd.get(), fooValue.get() );
|
||||
assert.ok( hasFooOnAdd );
|
||||
assert.equal( valuePassedToAdd.get(), fooValue.get() );
|
||||
|
||||
// Test events when removing the value.
|
||||
valuesInstance.bind( 'remove', function( value ) {
|
||||
@ -194,19 +194,19 @@ jQuery( function( $ ) {
|
||||
wasEventFiredOnRemoval = true;
|
||||
} );
|
||||
valuesInstance.remove( 'foo' );
|
||||
ok( hasFooOnRemove );
|
||||
equal( valuePassedToRemove.get(), fooValue.get() );
|
||||
ok( ! hasFooOnRemoved );
|
||||
equal( valuePassedToRemoved.get(), fooValue.get() );
|
||||
assert.ok( hasFooOnRemove );
|
||||
assert.equal( valuePassedToRemove.get(), fooValue.get() );
|
||||
assert.ok( ! hasFooOnRemoved );
|
||||
assert.equal( valuePassedToRemoved.get(), fooValue.get() );
|
||||
|
||||
// Confirm no events are fired when nonexistent value is removed.
|
||||
wasEventFiredOnRemoval = false;
|
||||
valuesInstance.remove( 'bar' );
|
||||
ok( ! wasEventFiredOnRemoval );
|
||||
assert.ok( ! wasEventFiredOnRemoval );
|
||||
});
|
||||
|
||||
module( 'Customize Base: Notification' );
|
||||
test( 'Notification object exists and has expected properties', function ( assert ) {
|
||||
QUnit.module( 'Customize Base: Notification' );
|
||||
QUnit.test( 'Notification object exists and has expected properties', function ( assert ) {
|
||||
var notification = new wp.customize.Notification( 'mycode', {
|
||||
'message': 'Hello World',
|
||||
'type': 'update',
|
||||
@ -231,8 +231,8 @@ jQuery( function( $ ) {
|
||||
assert.equal( null, notification.data );
|
||||
} );
|
||||
|
||||
module( 'Customize Base: utils.parseQueryString' );
|
||||
test( 'wp.customize.utils.parseQueryString works', function( assert ) {
|
||||
QUnit.module( 'Customize Base: utils.parseQueryString' );
|
||||
QUnit.test( 'wp.customize.utils.parseQueryString works', function( assert ) {
|
||||
var queryParams;
|
||||
queryParams = wp.customize.utils.parseQueryString( 'a=1&b=2' );
|
||||
assert.ok( _.isEqual( queryParams, { a: '1', b: '2' } ) );
|
||||
|
@ -4,7 +4,7 @@ jQuery( function( $ ) {
|
||||
var trueMockEvent, falseMockEvent, mockElementLists, $firstMockElement, $secondMockElement, $thirdMockElement,
|
||||
BubbleTester, BubbleTesterTwoValues, bubbleTesterParent, firstBubbleTester, secondBubbleTester;
|
||||
|
||||
module( 'Customizer Model Utility functions' );
|
||||
QUnit.module( 'Customizer Model Utility functions' );
|
||||
|
||||
trueMockEvent = {
|
||||
type : 'keydown',
|
||||
@ -16,12 +16,12 @@ jQuery( function( $ ) {
|
||||
which : 13
|
||||
};
|
||||
|
||||
test( 'isKeydownButNotEnterEvent returns true' , function () {
|
||||
ok( wp.customize.utils.isKeydownButNotEnterEvent( trueMockEvent ) );
|
||||
QUnit.test( 'isKeydownButNotEnterEvent returns true', function( assert ) {
|
||||
assert.ok( wp.customize.utils.isKeydownButNotEnterEvent( trueMockEvent ) );
|
||||
});
|
||||
|
||||
test( 'isKeydownButNotEnterEvent returns false' , function () {
|
||||
equal( wp.customize.utils.isKeydownButNotEnterEvent( falseMockEvent ) , false );
|
||||
QUnit.test( 'isKeydownButNotEnterEvent returns false', function( assert ) {
|
||||
assert.equal( wp.customize.utils.isKeydownButNotEnterEvent( falseMockEvent ) , false );
|
||||
});
|
||||
|
||||
$firstMockElement = $( '<div id="foo"></div>' );
|
||||
@ -36,20 +36,20 @@ jQuery( function( $ ) {
|
||||
thirdButLonger : [ $firstMockElement, $secondMockElement, $thirdMockElement ]
|
||||
};
|
||||
|
||||
test( 'areElementListsEqual returns true' , function () {
|
||||
ok( wp.customize.utils.areElementListsEqual( mockElementLists.first , mockElementLists.first ) );
|
||||
QUnit.test( 'areElementListsEqual returns true', function( assert ) {
|
||||
assert.ok( wp.customize.utils.areElementListsEqual( mockElementLists.first , mockElementLists.first ) );
|
||||
});
|
||||
|
||||
test( 'areElementListsEqual returns false' , function () {
|
||||
equal( wp.customize.utils.areElementListsEqual( mockElementLists.first , mockElementLists.second ) , false );
|
||||
QUnit.test( 'areElementListsEqual returns false', function( assert ) {
|
||||
assert.equal( wp.customize.utils.areElementListsEqual( mockElementLists.first , mockElementLists.second ) , false );
|
||||
});
|
||||
|
||||
test( 'areElementListsEqual: lists have same values, but in reverse order' , function () {
|
||||
equal( wp.customize.utils.areElementListsEqual( mockElementLists.first , mockElementLists.firstInReverseOrder ) , false );
|
||||
QUnit.test( 'areElementListsEqual: lists have same values, but in reverse order', function( assert ) {
|
||||
assert.equal( wp.customize.utils.areElementListsEqual( mockElementLists.first , mockElementLists.firstInReverseOrder ) , false );
|
||||
});
|
||||
|
||||
test( 'areElementListsEqual: lists have same values, but one is longer' , function () {
|
||||
equal( wp.customize.utils.areElementListsEqual( mockElementLists.third , mockElementLists.thirdButLonger ) , false );
|
||||
QUnit.test( 'areElementListsEqual: lists have same values, but one is longer', function( assert ) {
|
||||
assert.equal( wp.customize.utils.areElementListsEqual( mockElementLists.third , mockElementLists.thirdButLonger ) , false );
|
||||
});
|
||||
|
||||
|
||||
@ -72,15 +72,15 @@ jQuery( function( $ ) {
|
||||
}
|
||||
);
|
||||
|
||||
test( 'bubbleChildValueChanges notifies parent of change' , function() {
|
||||
QUnit.test( 'bubbleChildValueChanges notifies parent of change', function( assert ) {
|
||||
firstBubbleTester = new BubbleTester();
|
||||
wp.customize.utils.bubbleChildValueChanges( firstBubbleTester , [ 'fooValue' ] );
|
||||
firstBubbleTester.fooValue.set( 'new value' );
|
||||
ok( firstBubbleTester.parent.wasChangeTriggered );
|
||||
assert.ok( firstBubbleTester.parent.wasChangeTriggered );
|
||||
});
|
||||
|
||||
test( 'bubbleChildValueChanges passes a reference to its instance' , function() {
|
||||
ok( firstBubbleTester.parent.instancePassedInTrigger instanceof BubbleTester );
|
||||
QUnit.test( 'bubbleChildValueChanges passes a reference to its instance', function( assert ) {
|
||||
assert.ok( firstBubbleTester.parent.instancePassedInTrigger instanceof BubbleTester );
|
||||
});
|
||||
|
||||
BubbleTesterTwoValues = wp.customize.Class.extend(
|
||||
@ -98,11 +98,11 @@ jQuery( function( $ ) {
|
||||
wp.customize.utils.bubbleChildValueChanges( secondBubbleTester , [ 'exampleValue' , 'barValue' ] );
|
||||
secondBubbleTester.barValue.set( 'new value' );
|
||||
|
||||
test( 'bubbleChildValueChanges notifies parent of change when two values are bound' , function() {
|
||||
ok( secondBubbleTester.parent.wasChangeTriggered );
|
||||
QUnit.test( 'bubbleChildValueChanges notifies parent of change when two values are bound', function( assert ) {
|
||||
assert.ok( secondBubbleTester.parent.wasChangeTriggered );
|
||||
});
|
||||
|
||||
test( 'bubbleChildValueChanges passes a reference to its instance when two values are bound' , function() {
|
||||
ok( secondBubbleTester.parent.instancePassedInTrigger instanceof BubbleTesterTwoValues );
|
||||
QUnit.test( 'bubbleChildValueChanges passes a reference to its instance when two values are bound', function( assert ) {
|
||||
assert.ok( secondBubbleTester.parent.instancePassedInTrigger instanceof BubbleTesterTwoValues );
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* global JSON, wp, test, ok, equal, module */
|
||||
/* global JSON, wp */
|
||||
|
||||
wp.customize.settingConstructor.abbreviation = wp.customize.Setting.extend({
|
||||
validate: function( value ) {
|
||||
@ -6,7 +6,7 @@ wp.customize.settingConstructor.abbreviation = wp.customize.Setting.extend({
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( window ).load( function (){
|
||||
jQuery( window ).load( function() {
|
||||
'use strict';
|
||||
|
||||
var controlId, controlLabel, controlType, controlContent, controlDescription, controlData, mockControl,
|
||||
@ -19,76 +19,76 @@ jQuery( window ).load( function (){
|
||||
throw new Error( 'Must pass value type in expectedValues.' );
|
||||
}
|
||||
var type = expectedValues.type;
|
||||
test( 'Model extends proper type', function () {
|
||||
ok( model.extended( wp.customize[ type ] ) );
|
||||
QUnit.test( 'Model extends proper type', function( assert ) {
|
||||
assert.ok( model.extended( wp.customize[ type ] ) );
|
||||
} );
|
||||
|
||||
if ( expectedValues.hasOwnProperty( 'id' ) ) {
|
||||
test( type + ' instance has the right id', function () {
|
||||
equal( model.id, expectedValues.id );
|
||||
QUnit.test( type + ' instance has the right id', function( assert ) {
|
||||
assert.equal( model.id, expectedValues.id );
|
||||
});
|
||||
}
|
||||
if ( expectedValues.hasOwnProperty( 'title') ) {
|
||||
test( type + ' instance has the right title.', function () {
|
||||
equal( model.params.title, expectedValues.title );
|
||||
QUnit.test( type + ' instance has the right title.', function( assert ) {
|
||||
assert.equal( model.params.title, expectedValues.title );
|
||||
});
|
||||
}
|
||||
if ( expectedValues.hasOwnProperty( 'description' ) ) {
|
||||
test( type + ' instance has the right description.', function () {
|
||||
equal( model.params.description, expectedValues.description );
|
||||
QUnit.test( type + ' instance has the right description.', function( assert ) {
|
||||
assert.equal( model.params.description, expectedValues.description );
|
||||
});
|
||||
}
|
||||
if ( expectedValues.hasOwnProperty( 'content' ) ) {
|
||||
test( type + ' instance has the right content.', function () {
|
||||
equal( model.params.content, expectedValues.content );
|
||||
QUnit.test( type + ' instance has the right content.', function( assert ) {
|
||||
assert.equal( model.params.content, expectedValues.content );
|
||||
});
|
||||
}
|
||||
if ( expectedValues.hasOwnProperty( 'priority' ) ) {
|
||||
test( type + ' instance has the right priority.', function () {
|
||||
equal( model.priority(), expectedValues.priority );
|
||||
QUnit.test( type + ' instance has the right priority.', function( assert ) {
|
||||
assert.equal( model.priority(), expectedValues.priority );
|
||||
});
|
||||
}
|
||||
if ( expectedValues.hasOwnProperty( 'active' ) ) {
|
||||
test( type + ' instance has the right active state.', function () {
|
||||
equal( model.active(), expectedValues.active );
|
||||
QUnit.test( type + ' instance has the right active state.', function( assert ) {
|
||||
assert.equal( model.active(), expectedValues.active );
|
||||
});
|
||||
}
|
||||
test( type + ' can be deactivated', function () {
|
||||
QUnit.test( type + ' can be deactivated', function( assert ) {
|
||||
model.activate();
|
||||
model.deactivate();
|
||||
equal( model.active(), false );
|
||||
assert.equal( model.active(), false );
|
||||
model.activate();
|
||||
equal( model.active(), true );
|
||||
ok(true);
|
||||
assert.equal( model.active(), true );
|
||||
assert.ok(true);
|
||||
});
|
||||
|
||||
if ( type === 'Panel' || type === 'Section' ) {
|
||||
if ( expectedValues.hasOwnProperty( 'expanded' ) ) {
|
||||
test( type + ' instance has the right expanded state.', function () {
|
||||
equal( model.expanded(), expectedValues.expanded );
|
||||
QUnit.test( type + ' instance has the right expanded state.', function( assert ) {
|
||||
assert.equal( model.expanded(), expectedValues.expanded );
|
||||
} );
|
||||
}
|
||||
|
||||
test( type + ' instance is collapsed after calling .collapse()', function () {
|
||||
QUnit.test( type + ' instance is collapsed after calling .collapse()', function( assert ) {
|
||||
model.collapse();
|
||||
ok( ! model.expanded() );
|
||||
assert.ok( ! model.expanded() );
|
||||
});
|
||||
|
||||
test( type + ' instance is expanded after calling .expand()', function () {
|
||||
QUnit.test( type + ' instance is expanded after calling .expand()', function( assert ) {
|
||||
model.expand();
|
||||
ok( model.expanded() );
|
||||
assert.ok( model.expanded() );
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module( 'Customizer notifications collection' );
|
||||
test( 'Notifications collection exists', function() {
|
||||
ok( wp.customize.notifications );
|
||||
equal( wp.customize.notifications.defaultConstructor, wp.customize.Notification );
|
||||
QUnit.module( 'Customizer notifications collection' );
|
||||
QUnit.test( 'Notifications collection exists', function( assert ) {
|
||||
assert.ok( wp.customize.notifications );
|
||||
assert.equal( wp.customize.notifications.defaultConstructor, wp.customize.Notification );
|
||||
} );
|
||||
|
||||
test( 'Notification objects are rendered as part of notifications collection', function() {
|
||||
QUnit.test( 'Notification objects are rendered as part of notifications collection', function( assert ) {
|
||||
var container = jQuery( '#customize-notifications-test' ), items, collection;
|
||||
|
||||
collection = new wp.customize.Notifications({
|
||||
@ -97,8 +97,8 @@ jQuery( window ).load( function (){
|
||||
collection.add( 'mycode-1', new wp.customize.Notification( 'mycode-1', { message: 'My message 1' } ) );
|
||||
collection.render();
|
||||
items = collection.container.find( 'li' );
|
||||
equal( items.length, 1 );
|
||||
equal( items.first().data( 'code' ), 'mycode-1' );
|
||||
assert.equal( items.length, 1 );
|
||||
assert.equal( items.first().data( 'code' ), 'mycode-1' );
|
||||
|
||||
collection.add( 'mycode-2', new wp.customize.Notification( 'mycode-2', {
|
||||
message: 'My message 2',
|
||||
@ -106,69 +106,69 @@ jQuery( window ).load( function (){
|
||||
} ) );
|
||||
collection.render();
|
||||
items = collection.container.find( 'li' );
|
||||
equal( items.length, 2 );
|
||||
equal( items.first().data( 'code' ), 'mycode-2' );
|
||||
equal( items.last().data( 'code' ), 'mycode-1' );
|
||||
assert.equal( items.length, 2 );
|
||||
assert.equal( items.first().data( 'code' ), 'mycode-2' );
|
||||
assert.equal( items.last().data( 'code' ), 'mycode-1' );
|
||||
|
||||
equal( items.first().find( '.notice-dismiss' ).length, 1 );
|
||||
equal( items.last().find( '.notice-dismiss' ).length, 0 );
|
||||
assert.equal( items.first().find( '.notice-dismiss' ).length, 1 );
|
||||
assert.equal( items.last().find( '.notice-dismiss' ).length, 0 );
|
||||
|
||||
collection.remove( 'mycode-2' );
|
||||
collection.render();
|
||||
items = collection.container.find( 'li' );
|
||||
equal( items.length, 1 );
|
||||
equal( items.first().data( 'code' ), 'mycode-1' );
|
||||
assert.equal( items.length, 1 );
|
||||
assert.equal( items.first().data( 'code' ), 'mycode-1' );
|
||||
|
||||
collection.remove( 'mycode-1' );
|
||||
collection.render();
|
||||
ok( collection.container.is( ':hidden' ), 'Notifications area is hidden.' );
|
||||
assert.ok( collection.container.is( ':hidden' ), 'Notifications area is hidden.' );
|
||||
} );
|
||||
|
||||
module( 'Customizer Previewed Device' );
|
||||
test( 'Previewed device defaults to desktop.', function () {
|
||||
equal( wp.customize.previewedDevice.get(), 'desktop' );
|
||||
QUnit.module( 'Customizer Previewed Device' );
|
||||
QUnit.test( 'Previewed device defaults to desktop.', function( assert ) {
|
||||
assert.equal( wp.customize.previewedDevice.get(), 'desktop' );
|
||||
} );
|
||||
|
||||
module( 'Customizer Setting in Fixture' );
|
||||
test( 'Setting has fixture value', function () {
|
||||
equal( wp.customize( 'fixture-setting' )(), 'Lorem Ipsum' );
|
||||
QUnit.module( 'Customizer Setting in Fixture' );
|
||||
QUnit.test( 'Setting has fixture value', function( assert ) {
|
||||
assert.equal( wp.customize( 'fixture-setting' )(), 'Lorem Ipsum' );
|
||||
} );
|
||||
test( 'Setting has notifications', function () {
|
||||
QUnit.test( 'Setting has notifications', function( assert ) {
|
||||
var setting = wp.customize( 'fixture-setting' );
|
||||
ok( setting.notifications.extended( wp.customize.Values ) );
|
||||
equal( wp.customize.Notification, setting.notifications.prototype.constructor.defaultConstructor );
|
||||
assert.ok( setting.notifications.extended( wp.customize.Values ) );
|
||||
assert.equal( wp.customize.Notification, setting.notifications.prototype.constructor.defaultConstructor );
|
||||
} );
|
||||
test( 'Setting has findControls method', function() {
|
||||
QUnit.test( 'Setting has findControls method', function( assert ) {
|
||||
var controls, setting = wp.customize( 'fixture-setting' );
|
||||
equal( 'function', typeof setting.findControls );
|
||||
assert.equal( 'function', typeof setting.findControls );
|
||||
controls = setting.findControls();
|
||||
equal( 1, controls.length );
|
||||
equal( 'fixture-control', controls[0].id );
|
||||
assert.equal( 1, controls.length );
|
||||
assert.equal( 'fixture-control', controls[0].id );
|
||||
} );
|
||||
test( 'Setting constructor object exists', function( assert ) {
|
||||
QUnit.test( 'Setting constructor object exists', function( assert ) {
|
||||
assert.ok( _.isObject( wp.customize.settingConstructor ) );
|
||||
} );
|
||||
test( 'Custom setting constructor is used', function( assert ) {
|
||||
QUnit.test( 'Custom setting constructor is used', function( assert ) {
|
||||
var setting = wp.customize( 'fixture-setting-abbr' );
|
||||
assert.ok( setting.extended( wp.customize.settingConstructor.abbreviation ) );
|
||||
setting.set( 'usa' );
|
||||
assert.equal( 'USA', setting.get() );
|
||||
} );
|
||||
|
||||
module( 'Customizer Control in Fixture' );
|
||||
test( 'Control exists', function () {
|
||||
ok( wp.customize.control.has( 'fixture-control' ) );
|
||||
QUnit.module( 'Customizer Control in Fixture' );
|
||||
QUnit.test( 'Control exists', function( assert ) {
|
||||
assert.ok( wp.customize.control.has( 'fixture-control' ) );
|
||||
} );
|
||||
test( 'Control has the fixture setting', function () {
|
||||
QUnit.test( 'Control has the fixture setting', function( assert ) {
|
||||
var control = wp.customize.control( 'fixture-control' );
|
||||
equal( control.setting(), 'Lorem Ipsum' );
|
||||
equal( control.setting.id, 'fixture-setting' );
|
||||
assert.equal( control.setting(), 'Lorem Ipsum' );
|
||||
assert.equal( control.setting.id, 'fixture-setting' );
|
||||
} );
|
||||
test( 'Control has the section fixture section ID', function () {
|
||||
QUnit.test( 'Control has the section fixture section ID', function( assert ) {
|
||||
var control = wp.customize.control( 'fixture-control' );
|
||||
equal( control.section(), 'fixture-section' );
|
||||
assert.equal( control.section(), 'fixture-section' );
|
||||
} );
|
||||
test( 'Control has notifications', function ( assert ) {
|
||||
QUnit.test( 'Control has notifications', function ( assert ) {
|
||||
var control = wp.customize.control( 'fixture-control' ), settingNotification, controlOnlyNotification, doneEmbedded;
|
||||
assert.ok( control.notifications.extended( wp.customize.Values ) );
|
||||
assert.equal( wp.customize.Notification, control.notifications.prototype.constructor.defaultConstructor );
|
||||
@ -215,8 +215,8 @@ jQuery( window ).load( function (){
|
||||
} );
|
||||
} );
|
||||
|
||||
module( 'Customizer control without associated settings' );
|
||||
test( 'Control can be created without settings', function() {
|
||||
QUnit.module( 'Customizer control without associated settings' );
|
||||
QUnit.test( 'Control can be created without settings', function( assert ) {
|
||||
var control = new wp.customize.Control( 'settingless', {
|
||||
params: {
|
||||
content: jQuery( '<li class="settingless">Hello World</li>' ),
|
||||
@ -224,79 +224,79 @@ jQuery( window ).load( function (){
|
||||
}
|
||||
} );
|
||||
wp.customize.control.add( control.id, control );
|
||||
equal( control.deferred.embedded.state(), 'resolved' );
|
||||
ok( null === control.setting );
|
||||
ok( jQuery.isEmptyObject( control.settings ) );
|
||||
assert.equal( control.deferred.embedded.state(), 'resolved' );
|
||||
assert.ok( null === control.setting );
|
||||
assert.ok( jQuery.isEmptyObject( control.settings ) );
|
||||
} );
|
||||
|
||||
// Begin sections.
|
||||
module( 'Customizer Section in Fixture' );
|
||||
test( 'Fixture section exists', function () {
|
||||
ok( wp.customize.section.has( 'fixture-section' ) );
|
||||
QUnit.module( 'Customizer Section in Fixture' );
|
||||
QUnit.test( 'Fixture section exists', function( assert ) {
|
||||
assert.ok( wp.customize.section.has( 'fixture-section' ) );
|
||||
} );
|
||||
test( 'Fixture section has control among controls()', function () {
|
||||
QUnit.test( 'Fixture section has control among controls()', function( assert ) {
|
||||
var section = wp.customize.section( 'fixture-section' );
|
||||
ok( -1 !== _.pluck( section.controls(), 'id' ).indexOf( 'fixture-control' ) );
|
||||
assert.ok( -1 !== _.pluck( section.controls(), 'id' ).indexOf( 'fixture-control' ) );
|
||||
} );
|
||||
test( 'Fixture section has has expected panel', function () {
|
||||
QUnit.test( 'Fixture section has has expected panel', function( assert ) {
|
||||
var section = wp.customize.section( 'fixture-section' );
|
||||
equal( section.panel(), 'fixture-panel' );
|
||||
assert.equal( section.panel(), 'fixture-panel' );
|
||||
} );
|
||||
|
||||
module( 'Customizer Default Section with Template in Fixture' );
|
||||
test( 'Fixture section exists', function () {
|
||||
ok( wp.customize.section.has( 'fixture-section-default-templated' ) );
|
||||
QUnit.module( 'Customizer Default Section with Template in Fixture' );
|
||||
QUnit.test( 'Fixture section exists', function( assert ) {
|
||||
assert.ok( wp.customize.section.has( 'fixture-section-default-templated' ) );
|
||||
} );
|
||||
test( 'Fixture section has expected content', function () {
|
||||
QUnit.test( 'Fixture section has expected content', function( assert ) {
|
||||
var id = 'fixture-section-default-templated', section;
|
||||
section = wp.customize.section( id );
|
||||
ok( ! section.params.content );
|
||||
ok( !! section.container );
|
||||
ok( !! section.headContainer );
|
||||
ok( !! section.contentContainer );
|
||||
ok( section.container.has( section.headContainer ) );
|
||||
ok( section.container.has( section.contentContainer ) );
|
||||
ok( section.headContainer.is( '.control-section.control-section-default' ) );
|
||||
ok( 1 === section.headContainer.find( '> .accordion-section-title' ).length );
|
||||
ok( section.contentContainer.is( '.accordion-section-content' ) );
|
||||
equal( section.headContainer.attr( 'aria-owns' ), section.contentContainer.attr( 'id' ) );
|
||||
assert.ok( ! section.params.content );
|
||||
assert.ok( !! section.container );
|
||||
assert.ok( !! section.headContainer );
|
||||
assert.ok( !! section.contentContainer );
|
||||
assert.ok( section.container.has( section.headContainer ) );
|
||||
assert.ok( section.container.has( section.contentContainer ) );
|
||||
assert.ok( section.headContainer.is( '.control-section.control-section-default' ) );
|
||||
assert.ok( 1 === section.headContainer.find( '> .accordion-section-title' ).length );
|
||||
assert.ok( section.contentContainer.is( '.accordion-section-content' ) );
|
||||
assert.equal( section.headContainer.attr( 'aria-owns' ), section.contentContainer.attr( 'id' ) );
|
||||
} );
|
||||
|
||||
module( 'Customizer Custom Type (titleless) Section with Template in Fixture' );
|
||||
test( 'Fixture section exists', function () {
|
||||
ok( wp.customize.section.has( 'fixture-section-titleless-templated' ) );
|
||||
QUnit.module( 'Customizer Custom Type (titleless) Section with Template in Fixture' );
|
||||
QUnit.test( 'Fixture section exists', function( assert ) {
|
||||
assert.ok( wp.customize.section.has( 'fixture-section-titleless-templated' ) );
|
||||
} );
|
||||
test( 'Fixture section has expected content', function () {
|
||||
QUnit.test( 'Fixture section has expected content', function( assert ) {
|
||||
var id = 'fixture-section-titleless-templated', section;
|
||||
section = wp.customize.section( id );
|
||||
ok( ! section.params.content );
|
||||
ok( !! section.container );
|
||||
ok( !! section.headContainer );
|
||||
ok( !! section.contentContainer );
|
||||
ok( section.container.has( section.headContainer ) );
|
||||
ok( section.container.has( section.contentContainer ) );
|
||||
ok( section.container.is( '.control-section.control-section-titleless' ) );
|
||||
ok( 0 === section.headContainer.find( '> .accordion-section-title' ).length );
|
||||
ok( section.contentContainer.is( '.accordion-section-content' ) );
|
||||
equal( section.headContainer.attr( 'aria-owns' ), section.contentContainer.attr( 'id' ) );
|
||||
assert.ok( ! section.params.content );
|
||||
assert.ok( !! section.container );
|
||||
assert.ok( !! section.headContainer );
|
||||
assert.ok( !! section.contentContainer );
|
||||
assert.ok( section.container.has( section.headContainer ) );
|
||||
assert.ok( section.container.has( section.contentContainer ) );
|
||||
assert.ok( section.container.is( '.control-section.control-section-titleless' ) );
|
||||
assert.ok( 0 === section.headContainer.find( '> .accordion-section-title' ).length );
|
||||
assert.ok( section.contentContainer.is( '.accordion-section-content' ) );
|
||||
assert.equal( section.headContainer.attr( 'aria-owns' ), section.contentContainer.attr( 'id' ) );
|
||||
} );
|
||||
module( 'Customizer Custom Type Section Lacking Specific Template' );
|
||||
test( 'Fixture section has expected content', function () {
|
||||
QUnit.module( 'Customizer Custom Type Section Lacking Specific Template' );
|
||||
QUnit.test( 'Fixture section has expected content', function( assert ) {
|
||||
var id = 'fixture-section-reusing-default-template', section;
|
||||
section = wp.customize.section( id );
|
||||
ok( ! section.params.content );
|
||||
ok( !! section.container );
|
||||
ok( !! section.headContainer );
|
||||
ok( !! section.contentContainer );
|
||||
ok( section.container.has( section.headContainer ) );
|
||||
ok( section.container.has( section.contentContainer ) );
|
||||
ok( section.headContainer.is( '.control-section.control-section-' + section.params.type ) );
|
||||
ok( 1 === section.headContainer.find( '> .accordion-section-title' ).length );
|
||||
ok( section.contentContainer.is( '.accordion-section-content' ) );
|
||||
equal( section.headContainer.attr( 'aria-owns' ), section.contentContainer.attr( 'id' ) );
|
||||
assert.ok( ! section.params.content );
|
||||
assert.ok( !! section.container );
|
||||
assert.ok( !! section.headContainer );
|
||||
assert.ok( !! section.contentContainer );
|
||||
assert.ok( section.container.has( section.headContainer ) );
|
||||
assert.ok( section.container.has( section.contentContainer ) );
|
||||
assert.ok( section.headContainer.is( '.control-section.control-section-' + section.params.type ) );
|
||||
assert.ok( 1 === section.headContainer.find( '> .accordion-section-title' ).length );
|
||||
assert.ok( section.contentContainer.is( '.accordion-section-content' ) );
|
||||
assert.equal( section.headContainer.attr( 'aria-owns' ), section.contentContainer.attr( 'id' ) );
|
||||
} );
|
||||
module( 'Customizer Section lacking any params' );
|
||||
test( 'Fixture section has default params supplied', function () {
|
||||
QUnit.module( 'Customizer Section lacking any params' );
|
||||
QUnit.test( 'Fixture section has default params supplied', function( assert ) {
|
||||
var id = 'fixture-section-without-params', section, defaultParams;
|
||||
section = wp.customize.section( id );
|
||||
defaultParams = {
|
||||
@ -310,106 +310,106 @@ jQuery( window ).load( function (){
|
||||
customizeAction: ''
|
||||
};
|
||||
jQuery.each( defaultParams, function ( key, value ) {
|
||||
ok( 'undefined' !== typeof section.params[ key ] );
|
||||
equal( value, section.params[ key ] );
|
||||
assert.ok( 'undefined' !== typeof section.params[ key ] );
|
||||
assert.equal( value, section.params[ key ] );
|
||||
} );
|
||||
ok( _.isNumber( section.params.instanceNumber ) );
|
||||
assert.ok( _.isNumber( section.params.instanceNumber ) );
|
||||
} );
|
||||
|
||||
|
||||
// Begin panels.
|
||||
module( 'Customizer Panel in Fixture' );
|
||||
test( 'Fixture panel exists', function () {
|
||||
ok( wp.customize.panel.has( 'fixture-panel' ) );
|
||||
QUnit.module( 'Customizer Panel in Fixture' );
|
||||
QUnit.test( 'Fixture panel exists', function( assert ) {
|
||||
assert.ok( wp.customize.panel.has( 'fixture-panel' ) );
|
||||
} );
|
||||
test( 'Fixture panel has content', function () {
|
||||
QUnit.test( 'Fixture panel has content', function( assert ) {
|
||||
var panel = wp.customize.panel( 'fixture-panel' );
|
||||
ok( !! panel.params.content );
|
||||
ok( !! panel.container );
|
||||
ok( !! panel.headContainer );
|
||||
ok( !! panel.contentContainer );
|
||||
ok( panel.container.has( panel.headContainer ) );
|
||||
ok( panel.container.has( panel.contentContainer ) );
|
||||
assert.ok( !! panel.params.content );
|
||||
assert.ok( !! panel.container );
|
||||
assert.ok( !! panel.headContainer );
|
||||
assert.ok( !! panel.contentContainer );
|
||||
assert.ok( panel.container.has( panel.headContainer ) );
|
||||
assert.ok( panel.container.has( panel.contentContainer ) );
|
||||
} );
|
||||
test( 'Fixture panel has section among its sections()', function () {
|
||||
QUnit.test( 'Fixture panel has section among its sections()', function( assert ) {
|
||||
var panel = wp.customize.panel( 'fixture-panel' );
|
||||
ok( -1 !== _.pluck( panel.sections(), 'id' ).indexOf( 'fixture-section' ) );
|
||||
assert.ok( -1 !== _.pluck( panel.sections(), 'id' ).indexOf( 'fixture-section' ) );
|
||||
} );
|
||||
test( 'Panel is not expanded by default', function () {
|
||||
QUnit.test( 'Panel is not expanded by default', function( assert ) {
|
||||
var panel = wp.customize.panel( 'fixture-panel' );
|
||||
ok( ! panel.expanded() );
|
||||
assert.ok( ! panel.expanded() );
|
||||
} );
|
||||
test( 'Panel is not expanded by default', function () {
|
||||
QUnit.test( 'Panel is not expanded by default', function( assert ) {
|
||||
var panel = wp.customize.panel( 'fixture-panel' );
|
||||
ok( ! panel.expanded() );
|
||||
assert.ok( ! panel.expanded() );
|
||||
} );
|
||||
test( 'Focusing on a control will expand the panel and section', function () {
|
||||
QUnit.test( 'Focusing on a control will expand the panel and section', function( assert ) {
|
||||
var panel, section, control;
|
||||
panel = wp.customize.panel( 'fixture-panel' );
|
||||
section = wp.customize.section( 'fixture-section' );
|
||||
control = wp.customize.control( 'fixture-control' );
|
||||
ok( ! panel.expanded() );
|
||||
ok( ! section.expanded() );
|
||||
assert.ok( ! panel.expanded() );
|
||||
assert.ok( ! section.expanded() );
|
||||
control.focus();
|
||||
ok( section.expanded() );
|
||||
ok( panel.expanded() );
|
||||
assert.ok( section.expanded() );
|
||||
assert.ok( panel.expanded() );
|
||||
} );
|
||||
|
||||
module( 'Customizer Default Panel with Template in Fixture' );
|
||||
test( 'Fixture section exists', function () {
|
||||
ok( wp.customize.panel.has( 'fixture-panel-default-templated' ) );
|
||||
QUnit.module( 'Customizer Default Panel with Template in Fixture' );
|
||||
QUnit.test( 'Fixture section exists', function( assert ) {
|
||||
assert.ok( wp.customize.panel.has( 'fixture-panel-default-templated' ) );
|
||||
} );
|
||||
test( 'Fixture panel has expected content', function () {
|
||||
QUnit.test( 'Fixture panel has expected content', function( assert ) {
|
||||
var id = 'fixture-panel-default-templated', panel;
|
||||
panel = wp.customize.panel( id );
|
||||
ok( ! panel.params.content );
|
||||
ok( !! panel.container );
|
||||
ok( !! panel.headContainer );
|
||||
ok( !! panel.contentContainer );
|
||||
ok( panel.container.has( panel.headContainer ) );
|
||||
ok( panel.container.has( panel.contentContainer ) );
|
||||
ok( panel.headContainer.is( '.control-panel.control-panel-default' ) );
|
||||
ok( 1 === panel.headContainer.find( '> .accordion-section-title' ).length );
|
||||
ok( panel.contentContainer.is( '.control-panel-content' ) );
|
||||
equal( panel.headContainer.attr( 'aria-owns' ), panel.contentContainer.attr( 'id' ) );
|
||||
assert.ok( ! panel.params.content );
|
||||
assert.ok( !! panel.container );
|
||||
assert.ok( !! panel.headContainer );
|
||||
assert.ok( !! panel.contentContainer );
|
||||
assert.ok( panel.container.has( panel.headContainer ) );
|
||||
assert.ok( panel.container.has( panel.contentContainer ) );
|
||||
assert.ok( panel.headContainer.is( '.control-panel.control-panel-default' ) );
|
||||
assert.ok( 1 === panel.headContainer.find( '> .accordion-section-title' ).length );
|
||||
assert.ok( panel.contentContainer.is( '.control-panel-content' ) );
|
||||
assert.equal( panel.headContainer.attr( 'aria-owns' ), panel.contentContainer.attr( 'id' ) );
|
||||
} );
|
||||
|
||||
module( 'Customizer Custom Type Panel (titleless) with Template in Fixture' );
|
||||
test( 'Fixture panel exists', function () {
|
||||
ok( wp.customize.panel.has( 'fixture-panel-titleless-templated' ) );
|
||||
QUnit.module( 'Customizer Custom Type Panel (titleless) with Template in Fixture' );
|
||||
QUnit.test( 'Fixture panel exists', function( assert ) {
|
||||
assert.ok( wp.customize.panel.has( 'fixture-panel-titleless-templated' ) );
|
||||
} );
|
||||
test( 'Fixture panel has expected content', function () {
|
||||
QUnit.test( 'Fixture panel has expected content', function( assert ) {
|
||||
var id = 'fixture-panel-titleless-templated', panel;
|
||||
panel = wp.customize.panel( id );
|
||||
ok( ! panel.params.content );
|
||||
ok( !! panel.container );
|
||||
ok( !! panel.headContainer );
|
||||
ok( !! panel.contentContainer );
|
||||
ok( panel.container.has( panel.headContainer ) );
|
||||
ok( panel.container.has( panel.contentContainer ) );
|
||||
ok( panel.headContainer.is( '.control-panel.control-panel-titleless' ) );
|
||||
ok( 0 === panel.headContainer.find( '> .accordion-section-title' ).length );
|
||||
ok( panel.contentContainer.is( '.control-panel-content' ) );
|
||||
equal( panel.headContainer.attr( 'aria-owns' ), panel.contentContainer.attr( 'id' ) );
|
||||
assert.ok( ! panel.params.content );
|
||||
assert.ok( !! panel.container );
|
||||
assert.ok( !! panel.headContainer );
|
||||
assert.ok( !! panel.contentContainer );
|
||||
assert.ok( panel.container.has( panel.headContainer ) );
|
||||
assert.ok( panel.container.has( panel.contentContainer ) );
|
||||
assert.ok( panel.headContainer.is( '.control-panel.control-panel-titleless' ) );
|
||||
assert.ok( 0 === panel.headContainer.find( '> .accordion-section-title' ).length );
|
||||
assert.ok( panel.contentContainer.is( '.control-panel-content' ) );
|
||||
assert.equal( panel.headContainer.attr( 'aria-owns' ), panel.contentContainer.attr( 'id' ) );
|
||||
} );
|
||||
|
||||
module( 'Customizer Custom Type Panel Lacking Specific Template' );
|
||||
test( 'Fixture panel has expected content', function () {
|
||||
QUnit.module( 'Customizer Custom Type Panel Lacking Specific Template' );
|
||||
QUnit.test( 'Fixture panel has expected content', function( assert ) {
|
||||
var id = 'fixture-panel-reusing-default-template', panel;
|
||||
panel = wp.customize.panel( id );
|
||||
ok( ! panel.params.content );
|
||||
ok( !! panel.container );
|
||||
ok( !! panel.headContainer );
|
||||
ok( !! panel.contentContainer );
|
||||
ok( panel.container.has( panel.headContainer ) );
|
||||
ok( panel.container.has( panel.contentContainer ) );
|
||||
ok( panel.headContainer.is( '.control-panel.control-panel-' + panel.params.type ) );
|
||||
ok( 1 === panel.headContainer.find( '> .accordion-section-title' ).length );
|
||||
ok( panel.contentContainer.is( '.control-panel-content' ) );
|
||||
equal( panel.headContainer.attr( 'aria-owns' ), panel.contentContainer.attr( 'id' ) );
|
||||
assert.ok( ! panel.params.content );
|
||||
assert.ok( !! panel.container );
|
||||
assert.ok( !! panel.headContainer );
|
||||
assert.ok( !! panel.contentContainer );
|
||||
assert.ok( panel.container.has( panel.headContainer ) );
|
||||
assert.ok( panel.container.has( panel.contentContainer ) );
|
||||
assert.ok( panel.headContainer.is( '.control-panel.control-panel-' + panel.params.type ) );
|
||||
assert.ok( 1 === panel.headContainer.find( '> .accordion-section-title' ).length );
|
||||
assert.ok( panel.contentContainer.is( '.control-panel-content' ) );
|
||||
assert.equal( panel.headContainer.attr( 'aria-owns' ), panel.contentContainer.attr( 'id' ) );
|
||||
} );
|
||||
module( 'Customizer Panel lacking any params' );
|
||||
test( 'Fixture panel has default params supplied', function () {
|
||||
QUnit.module( 'Customizer Panel lacking any params' );
|
||||
QUnit.test( 'Fixture panel has default params supplied', function( assert ) {
|
||||
var id = 'fixture-panel-without-params', panel, defaultParams;
|
||||
panel = wp.customize.panel( id );
|
||||
defaultParams = {
|
||||
@ -421,17 +421,17 @@ jQuery( window ).load( function (){
|
||||
active: true
|
||||
};
|
||||
jQuery.each( defaultParams, function ( key, value ) {
|
||||
ok( 'undefined' !== typeof panel.params[ key ] );
|
||||
equal( value, panel.params[ key ] );
|
||||
assert.ok( 'undefined' !== typeof panel.params[ key ] );
|
||||
assert.equal( value, panel.params[ key ] );
|
||||
} );
|
||||
ok( _.isNumber( panel.params.instanceNumber ) );
|
||||
assert.ok( _.isNumber( panel.params.instanceNumber ) );
|
||||
} );
|
||||
|
||||
module( 'Dynamically-created Customizer Setting Model' );
|
||||
QUnit.module( 'Dynamically-created Customizer Setting Model' );
|
||||
settingId = 'new_blogname';
|
||||
settingValue = 'Hello World';
|
||||
|
||||
test( 'Create a new setting', function () {
|
||||
QUnit.test( 'Create a new setting', function( assert ) {
|
||||
mockSetting = wp.customize.create(
|
||||
settingId,
|
||||
settingId,
|
||||
@ -441,11 +441,11 @@ jQuery( window ).load( function (){
|
||||
previewer: wp.customize.previewer
|
||||
}
|
||||
);
|
||||
equal( mockSetting(), settingValue );
|
||||
equal( mockSetting.id, settingId );
|
||||
assert.equal( mockSetting(), settingValue );
|
||||
assert.equal( mockSetting.id, settingId );
|
||||
} );
|
||||
|
||||
module( 'Dynamically-created Customizer Section Model' );
|
||||
QUnit.module( 'Dynamically-created Customizer Section Model' );
|
||||
|
||||
sectionId = 'mock_title_tagline';
|
||||
sectionContent = '<li id="accordion-section-mock_title_tagline" class="accordion-section control-section control-section-default"> <h3 class="accordion-section-title" tabindex="0"> Section Fixture <span class="screen-reader-text">Press return or enter to open</span> </h3> <ul class="accordion-section-content"> <li class="customize-section-description-container"> <div class="customize-section-title"> <button class="customize-section-back" tabindex="-1"> <span class="screen-reader-text">Back</span> </button> <h3> <span class="customize-action">Customizing ▸ Fixture Panel</span> Section Fixture </h3> </div> </li> </ul> </li>';
|
||||
@ -467,27 +467,27 @@ jQuery( window ).load( function (){
|
||||
|
||||
testCustomizerModel( mockSection, sectionExpectedValues );
|
||||
|
||||
test( 'Section has been embedded', function () {
|
||||
equal( mockSection.deferred.embedded.state(), 'resolved' );
|
||||
QUnit.test( 'Section has been embedded', function( assert ) {
|
||||
assert.equal( mockSection.deferred.embedded.state(), 'resolved' );
|
||||
} );
|
||||
|
||||
wp.customize.section.add( sectionId, mockSection );
|
||||
|
||||
test( 'Section instance added to the wp.customize.section object', function () {
|
||||
ok( wp.customize.section.has( sectionId ) );
|
||||
QUnit.test( 'Section instance added to the wp.customize.section object', function( assert ) {
|
||||
assert.ok( wp.customize.section.has( sectionId ) );
|
||||
});
|
||||
|
||||
sectionInstance = wp.customize.section( sectionId );
|
||||
|
||||
test( 'Section instance has right content when accessed from wp.customize.section()', function () {
|
||||
equal( sectionInstance.params.content, sectionContent );
|
||||
QUnit.test( 'Section instance has right content when accessed from wp.customize.section()', function( assert ) {
|
||||
assert.equal( sectionInstance.params.content, sectionContent );
|
||||
});
|
||||
|
||||
test( 'Section instance has no children yet', function () {
|
||||
equal( sectionInstance.controls().length, 0 );
|
||||
QUnit.test( 'Section instance has no children yet', function( assert ) {
|
||||
assert.equal( sectionInstance.controls().length, 0 );
|
||||
});
|
||||
|
||||
module( 'Dynamically-created Customizer Control Model' );
|
||||
QUnit.module( 'Dynamically-created Customizer Control Model' );
|
||||
|
||||
controlId = 'new_blogname';
|
||||
controlLabel = 'Site Title';
|
||||
@ -520,43 +520,43 @@ jQuery( window ).load( function (){
|
||||
|
||||
testCustomizerModel( mockControl, controlExpectedValues );
|
||||
|
||||
test( 'Control instance does not yet belong to a section.', function () {
|
||||
equal( mockControl.section(), undefined );
|
||||
QUnit.test( 'Control instance does not yet belong to a section.', function( assert ) {
|
||||
assert.equal( mockControl.section(), undefined );
|
||||
});
|
||||
test( 'Control has not been embedded yet', function () {
|
||||
equal( mockControl.deferred.embedded.state(), 'pending' );
|
||||
QUnit.test( 'Control has not been embedded yet', function( assert ) {
|
||||
assert.equal( mockControl.deferred.embedded.state(), 'pending' );
|
||||
} );
|
||||
|
||||
test( 'Control instance has the right selector.', function () {
|
||||
equal( mockControl.selector, '#customize-control-new_blogname' );
|
||||
QUnit.test( 'Control instance has the right selector.', function( assert ) {
|
||||
assert.equal( mockControl.selector, '#customize-control-new_blogname' );
|
||||
});
|
||||
|
||||
wp.customize.control.add( controlId, mockControl );
|
||||
|
||||
test( 'Control instance was added to the control class.', function () {
|
||||
ok( wp.customize.control.has( controlId ) );
|
||||
QUnit.test( 'Control instance was added to the control class.', function( assert ) {
|
||||
assert.ok( wp.customize.control.has( controlId ) );
|
||||
});
|
||||
|
||||
mockControlInstance = wp.customize.control( controlId );
|
||||
|
||||
test( 'Control instance has the right id when accessed from api.control().', function () {
|
||||
equal( mockControlInstance.id, controlId );
|
||||
QUnit.test( 'Control instance has the right id when accessed from api.control().', function( assert ) {
|
||||
assert.equal( mockControlInstance.id, controlId );
|
||||
});
|
||||
|
||||
test( 'Control section can be set as expected', function () {
|
||||
QUnit.test( 'Control section can be set as expected', function( assert ) {
|
||||
mockControl.section( mockSection.id );
|
||||
equal( mockControl.section(), mockSection.id );
|
||||
assert.equal( mockControl.section(), mockSection.id );
|
||||
});
|
||||
test( 'Associating a control with a section allows it to be embedded', function () {
|
||||
equal( mockControl.deferred.embedded.state(), 'resolved' );
|
||||
QUnit.test( 'Associating a control with a section allows it to be embedded', function( assert ) {
|
||||
assert.equal( mockControl.deferred.embedded.state(), 'resolved' );
|
||||
});
|
||||
|
||||
test( 'Control is now available on section.controls()', function () {
|
||||
equal( sectionInstance.controls().length, 1 );
|
||||
equal( sectionInstance.controls()[0], mockControl );
|
||||
QUnit.test( 'Control is now available on section.controls()', function( assert ) {
|
||||
assert.equal( sectionInstance.controls().length, 1 );
|
||||
assert.equal( sectionInstance.controls()[0], mockControl );
|
||||
});
|
||||
|
||||
module( 'Dynamically-created Customizer Panel Model' );
|
||||
QUnit.module( 'Dynamically-created Customizer Panel Model' );
|
||||
|
||||
panelId = 'mockPanelId';
|
||||
panelTitle = 'Mock Panel Title';
|
||||
@ -584,49 +584,49 @@ jQuery( window ).load( function (){
|
||||
|
||||
testCustomizerModel( mockPanel, panelExpectedValues );
|
||||
|
||||
test( 'Panel instance is not contextuallyActive', function () {
|
||||
equal( mockPanel.isContextuallyActive(), false );
|
||||
QUnit.test( 'Panel instance is not contextuallyActive', function( assert ) {
|
||||
assert.equal( mockPanel.isContextuallyActive(), false );
|
||||
});
|
||||
|
||||
module( 'Test wp.customize.findControlsForSettings' );
|
||||
test( 'findControlsForSettings(blogname)', function() {
|
||||
QUnit.module( 'Test wp.customize.findControlsForSettings' );
|
||||
QUnit.test( 'findControlsForSettings(blogname)', function( assert ) {
|
||||
var controlsForSettings, settingId = 'fixture-setting', controlId = 'fixture-control';
|
||||
ok( wp.customize.control.has( controlId ) );
|
||||
ok( wp.customize.has( settingId ) );
|
||||
assert.ok( wp.customize.control.has( controlId ) );
|
||||
assert.ok( wp.customize.has( settingId ) );
|
||||
controlsForSettings = wp.customize.findControlsForSettings( [ settingId ] );
|
||||
ok( _.isObject( controlsForSettings ), 'Response is object' );
|
||||
ok( _.isArray( controlsForSettings['fixture-setting'] ), 'Response has a fixture-setting array' );
|
||||
equal( 1, controlsForSettings['fixture-setting'].length );
|
||||
equal( wp.customize.control( controlId ), controlsForSettings['fixture-setting'][0] );
|
||||
assert.ok( _.isObject( controlsForSettings ), 'Response is object' );
|
||||
assert.ok( _.isArray( controlsForSettings['fixture-setting'] ), 'Response has a fixture-setting array' );
|
||||
assert.equal( 1, controlsForSettings['fixture-setting'].length );
|
||||
assert.equal( wp.customize.control( controlId ), controlsForSettings['fixture-setting'][0] );
|
||||
} );
|
||||
|
||||
module( 'Customize Controls wp.customize.dirtyValues' );
|
||||
test( 'dirtyValues() returns expected values', function() {
|
||||
QUnit.module( 'Customize Controls wp.customize.dirtyValues' );
|
||||
QUnit.test( 'dirtyValues() returns expected values', function( assert ) {
|
||||
wp.customize.state( 'changesetStatus' ).set( 'auto-draft' );
|
||||
wp.customize.each( function( setting ) {
|
||||
setting._dirty = false;
|
||||
} );
|
||||
ok( _.isEmpty( wp.customize.dirtyValues() ) );
|
||||
ok( _.isEmpty( wp.customize.dirtyValues( { unsaved: false } ) ) );
|
||||
assert.ok( _.isEmpty( wp.customize.dirtyValues() ) );
|
||||
assert.ok( _.isEmpty( wp.customize.dirtyValues( { unsaved: false } ) ) );
|
||||
|
||||
wp.customize( 'fixture-setting' )._dirty = true;
|
||||
ok( ! _.isEmpty( wp.customize.dirtyValues() ) );
|
||||
ok( _.isEmpty( wp.customize.dirtyValues( { unsaved: true } ) ) );
|
||||
assert.ok( ! _.isEmpty( wp.customize.dirtyValues() ) );
|
||||
assert.ok( _.isEmpty( wp.customize.dirtyValues( { unsaved: true } ) ) );
|
||||
|
||||
wp.customize( 'fixture-setting' ).set( 'Modified' );
|
||||
ok( ! _.isEmpty( wp.customize.dirtyValues() ) );
|
||||
ok( ! _.isEmpty( wp.customize.dirtyValues( { unsaved: true } ) ) );
|
||||
equal( 'Modified', wp.customize.dirtyValues()['fixture-setting'] );
|
||||
assert.ok( ! _.isEmpty( wp.customize.dirtyValues() ) );
|
||||
assert.ok( ! _.isEmpty( wp.customize.dirtyValues( { unsaved: true } ) ) );
|
||||
assert.equal( 'Modified', wp.customize.dirtyValues()['fixture-setting'] );
|
||||
|
||||
// When the changeset does not exist, all dirty settings are necessarily unsaved.
|
||||
wp.customize.state( 'changesetStatus' ).set( '' );
|
||||
wp.customize( 'fixture-setting' )._dirty = true;
|
||||
ok( ! _.isEmpty( wp.customize.dirtyValues() ) );
|
||||
ok( ! _.isEmpty( wp.customize.dirtyValues( { unsaved: true } ) ) );
|
||||
assert.ok( ! _.isEmpty( wp.customize.dirtyValues() ) );
|
||||
assert.ok( ! _.isEmpty( wp.customize.dirtyValues( { unsaved: true } ) ) );
|
||||
} );
|
||||
|
||||
module( 'Customize Controls: wp.customize.requestChangesetUpdate()' );
|
||||
test( 'requestChangesetUpdate makes request and returns promise', function( assert ) {
|
||||
QUnit.module( 'Customize Controls: wp.customize.requestChangesetUpdate()' );
|
||||
QUnit.test( 'requestChangesetUpdate makes request and returns promise', function( assert ) {
|
||||
var request, originalBeforeSetup = jQuery.ajaxSettings.beforeSend;
|
||||
|
||||
jQuery.ajaxSetup( {
|
||||
@ -677,8 +677,8 @@ jQuery( window ).load( function (){
|
||||
} );
|
||||
} );
|
||||
|
||||
module( 'Customize Utils: wp.customize.utils.getRemainingTime()' );
|
||||
test( 'utils.getRemainingTime calculates time correctly', function( assert ) {
|
||||
QUnit.module( 'Customize Utils: wp.customize.utils.getRemainingTime()' );
|
||||
QUnit.test( 'utils.getRemainingTime calculates time correctly', function( assert ) {
|
||||
var datetime = '2599-08-06 12:12:13', timeRemaining, timeRemainingWithDateInstance, timeRemaingingWithTimestamp;
|
||||
|
||||
timeRemaining = wp.customize.utils.getRemainingTime( datetime );
|
||||
@ -692,15 +692,15 @@ jQuery( window ).load( function (){
|
||||
assert.deepEqual( timeRemaining, timeRemaingingWithTimestamp );
|
||||
});
|
||||
|
||||
module( 'Customize Utils: wp.customize.utils.getCurrentTimestamp()' );
|
||||
test( 'utils.getCurrentTimestamp returns timestamp', function( assert ) {
|
||||
QUnit.module( 'Customize Utils: wp.customize.utils.getCurrentTimestamp()' );
|
||||
QUnit.test( 'utils.getCurrentTimestamp returns timestamp', function( assert ) {
|
||||
var currentTimeStamp;
|
||||
currentTimeStamp = wp.customize.utils.getCurrentTimestamp();
|
||||
assert.equal( typeof currentTimeStamp, 'number' );
|
||||
});
|
||||
|
||||
module( 'Customize Controls: wp.customize.DateTimeControl' );
|
||||
test( 'Test DateTimeControl creation and its methods', function( assert ) {
|
||||
QUnit.module( 'Customize Controls: wp.customize.DateTimeControl' );
|
||||
QUnit.test( 'Test DateTimeControl creation and its methods', function( assert ) {
|
||||
var control, controlId = 'date_time', section, sectionId = 'fixture-section',
|
||||
datetime = '2599-08-06 18:12:13', dateTimeArray, dateTimeArrayInampm, timeString,
|
||||
day, year, month, minute, meridian, hour;
|
||||
@ -864,8 +864,8 @@ jQuery( window ).load( function (){
|
||||
wp.customize.control.remove( controlId );
|
||||
});
|
||||
|
||||
module( 'Customize Sections: wp.customize.OuterSection' );
|
||||
test( 'Test OuterSection', function( assert ) {
|
||||
QUnit.module( 'Customize Sections: wp.customize.OuterSection' );
|
||||
QUnit.test( 'Test OuterSection', function( assert ) {
|
||||
var section, sectionId = 'test_outer_section', body = jQuery( 'body' ),
|
||||
defaultSection, defaultSectionId = 'fixture-section';
|
||||
|
||||
@ -899,8 +899,8 @@ jQuery( window ).load( function (){
|
||||
wp.customize.section.remove( sectionId );
|
||||
});
|
||||
|
||||
module( 'Customize Controls: PreviewLinkControl' );
|
||||
test( 'Test PreviewLinkControl creation and its methods', function( assert ) {
|
||||
QUnit.module( 'Customize Controls: PreviewLinkControl' );
|
||||
QUnit.test( 'Test PreviewLinkControl creation and its methods', function( assert ) {
|
||||
var section, sectionId = 'publish_settings', newLink;
|
||||
|
||||
section = wp.customize.section( sectionId );
|
||||
|
@ -1,48 +1,48 @@
|
||||
/* global wp, sinon */
|
||||
|
||||
jQuery( function() {
|
||||
module('Custom Header: ChoiceList', {
|
||||
setup: function() {
|
||||
QUnit.module('Custom Header: ChoiceList', {
|
||||
beforeEach: function() {
|
||||
wp.customize.HeaderTool.currentHeader = new wp.customize.HeaderTool.ImageModel();
|
||||
this.apiStub = sinon.stub(wp.customize, 'get').returns('foo');
|
||||
this.choiceList = new wp.customize.HeaderTool.ChoiceList();
|
||||
},
|
||||
teardown: function() {
|
||||
afterEach: function() {
|
||||
this.apiStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('should parse _wpCustomizeHeader.uploads into itself', function() {
|
||||
equal(this.choiceList.length, 4);
|
||||
QUnit.test('should parse _wpCustomizeHeader.uploads into itself', function( assert ) {
|
||||
assert.equal(this.choiceList.length, 4);
|
||||
});
|
||||
|
||||
test('should sort by newest first', function() {
|
||||
equal(this.choiceList.at(2).get('header').attachment_id, 1);
|
||||
equal(this.choiceList.first().get('header').attachment_id, 3);
|
||||
QUnit.test('should sort by newest first', function( assert ) {
|
||||
assert.equal(this.choiceList.at(2).get('header').attachment_id, 1);
|
||||
assert.equal(this.choiceList.first().get('header').attachment_id, 3);
|
||||
});
|
||||
|
||||
module('Custom Header: DefaultsList', {
|
||||
setup: function() {
|
||||
QUnit.module('Custom Header: DefaultsList', {
|
||||
beforeEach: function() {
|
||||
wp.customize.HeaderTool.currentHeader = new wp.customize.HeaderTool.ImageModel();
|
||||
this.apiStub = sinon.stub(wp.customize, 'get').returns('foo');
|
||||
this.choiceList = new wp.customize.HeaderTool.DefaultsList();
|
||||
},
|
||||
teardown: function() {
|
||||
afterEach: function() {
|
||||
this.apiStub.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('it should parse _wpCustomizeHeader.defaults into itself', function() {
|
||||
equal(this.choiceList.length, 4);
|
||||
QUnit.test('it should parse _wpCustomizeHeader.defaults into itself', function( assert ) {
|
||||
assert.equal(this.choiceList.length, 4);
|
||||
});
|
||||
|
||||
test('it parses the default image names', function() {
|
||||
equal(this.choiceList.first().get('header').defaultName, 'circle');
|
||||
equal(this.choiceList.at(2).get('header').defaultName, 'star');
|
||||
QUnit.test('it parses the default image names', function( assert ) {
|
||||
assert.equal(this.choiceList.first().get('header').defaultName, 'circle');
|
||||
assert.equal(this.choiceList.at(2).get('header').defaultName, 'star');
|
||||
});
|
||||
|
||||
module('Custom Header: HeaderImage shouldBeCropped()', {
|
||||
setup: function() {
|
||||
QUnit.module('Custom Header: HeaderImage shouldBeCropped()', {
|
||||
beforeEach: function() {
|
||||
wp.customize.HeaderTool.currentHeader = new wp.customize.HeaderTool.ImageModel();
|
||||
this.model = new wp.customize.HeaderTool.ImageModel();
|
||||
this.model.set({
|
||||
@ -52,7 +52,7 @@ jQuery( function() {
|
||||
}
|
||||
});
|
||||
|
||||
test('should not be cropped when the theme does not support flex width or height and the image has the same dimensions of the theme image', function() {
|
||||
QUnit.test('should not be cropped when the theme does not support flex width or height and the image has the same dimensions of the theme image', function( assert ) {
|
||||
this.model.set({
|
||||
themeFlexWidth: false,
|
||||
themeFlexHeight: false,
|
||||
@ -60,10 +60,10 @@ jQuery( function() {
|
||||
imageHeight: 200
|
||||
});
|
||||
|
||||
equal(this.model.shouldBeCropped(), false);
|
||||
assert.equal(this.model.shouldBeCropped(), false);
|
||||
});
|
||||
|
||||
test('should be cropped when the image has the same dimensions of the theme image', function() {
|
||||
QUnit.test('should be cropped when the image has the same dimensions of the theme image', function( assert ) {
|
||||
this.model.set({
|
||||
themeFlexWidth: false,
|
||||
themeFlexHeight: false,
|
||||
@ -71,10 +71,10 @@ jQuery( function() {
|
||||
imageHeight: 400
|
||||
});
|
||||
|
||||
equal(this.model.shouldBeCropped(), true);
|
||||
assert.equal(this.model.shouldBeCropped(), true);
|
||||
});
|
||||
|
||||
test('should not be cropped when the theme only supports flex width and the image has the same height as the theme image', function() {
|
||||
QUnit.test('should not be cropped when the theme only supports flex width and the image has the same height as the theme image', function( assert ) {
|
||||
this.model.set({
|
||||
themeFlexWidth: true,
|
||||
themeFlexHeight: false,
|
||||
@ -82,10 +82,10 @@ jQuery( function() {
|
||||
imageHeight: 200
|
||||
});
|
||||
|
||||
equal(this.model.shouldBeCropped(), false);
|
||||
assert.equal(this.model.shouldBeCropped(), false);
|
||||
});
|
||||
|
||||
test('should not be cropped when the theme only supports flex height and the image has the same width as the theme image', function() {
|
||||
QUnit.test('should not be cropped when the theme only supports flex height and the image has the same width as the theme image', function( assert ) {
|
||||
this.model.set({
|
||||
themeFlexWidth: false,
|
||||
themeFlexHeight: true,
|
||||
@ -93,10 +93,10 @@ jQuery( function() {
|
||||
imageHeight: 600
|
||||
});
|
||||
|
||||
equal(this.model.shouldBeCropped(), false);
|
||||
assert.equal(this.model.shouldBeCropped(), false);
|
||||
});
|
||||
|
||||
test('should not be cropped when the theme supports flex height AND width', function() {
|
||||
QUnit.test('should not be cropped when the theme supports flex height AND width', function( assert ) {
|
||||
this.model.set({
|
||||
themeFlexWidth: true,
|
||||
themeFlexHeight: true,
|
||||
@ -104,10 +104,10 @@ jQuery( function() {
|
||||
imageHeight: 8600
|
||||
});
|
||||
|
||||
equal(this.model.shouldBeCropped(), false);
|
||||
assert.equal(this.model.shouldBeCropped(), false);
|
||||
});
|
||||
|
||||
test('should not be cropped when the image width is smaller than or equal to theme width', function() {
|
||||
QUnit.test('should not be cropped when the image width is smaller than or equal to theme width', function( assert ) {
|
||||
this.model.set({
|
||||
themeFlexWidth: false,
|
||||
themeFlexHeight: false,
|
||||
@ -115,10 +115,10 @@ jQuery( function() {
|
||||
imageHeight: 100
|
||||
});
|
||||
|
||||
equal(this.model.shouldBeCropped(), false);
|
||||
assert.equal(this.model.shouldBeCropped(), false);
|
||||
});
|
||||
|
||||
test('should not be cropped when the image width is smaller than or equal to theme width, theme supports flex height and width', function() {
|
||||
QUnit.test('should not be cropped when the image width is smaller than or equal to theme width, theme supports flex height and width', function( assert ) {
|
||||
this.model.set({
|
||||
themeFlexWidth: true,
|
||||
themeFlexHeight: true,
|
||||
@ -126,6 +126,6 @@ jQuery( function() {
|
||||
imageHeight: 100
|
||||
});
|
||||
|
||||
equal(this.model.shouldBeCropped(), false);
|
||||
assert.equal(this.model.shouldBeCropped(), false);
|
||||
});
|
||||
});
|
||||
|
@ -1,109 +1,109 @@
|
||||
/* global wp */
|
||||
jQuery( window ).load( function (){
|
||||
jQuery( window ).load( function() {
|
||||
|
||||
var api = wp.customize,
|
||||
primaryMenuId = 3,
|
||||
socialMenuId = 2;
|
||||
|
||||
module( 'Customize Nav Menus' );
|
||||
QUnit.module( 'Customize Nav Menus' );
|
||||
|
||||
/**
|
||||
* Generate 20 IDs and verify they are all unique.
|
||||
*/
|
||||
test( 'generatePlaceholderAutoIncrementId generates unique IDs', function() {
|
||||
QUnit.test( 'generatePlaceholderAutoIncrementId generates unique IDs', function( assert ) {
|
||||
var testIterations = 20,
|
||||
ids = [ api.Menus.generatePlaceholderAutoIncrementId() ];
|
||||
|
||||
while ( testIterations ) {
|
||||
var placeholderID = api.Menus.generatePlaceholderAutoIncrementId();
|
||||
|
||||
ok( -1 === ids.indexOf( placeholderID ) );
|
||||
assert.ok( -1 === ids.indexOf( placeholderID ) );
|
||||
ids.push( placeholderID );
|
||||
testIterations -= 1;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
test( 'it should parse _wpCustomizeMenusSettings.defaults into itself', function() {
|
||||
deepEqual( window._wpCustomizeNavMenusSettings, api.Menus.data );
|
||||
QUnit.test( 'it should parse _wpCustomizeMenusSettings.defaults into itself', function( assert ) {
|
||||
assert.deepEqual( window._wpCustomizeNavMenusSettings, api.Menus.data );
|
||||
} );
|
||||
|
||||
test( 'empty menus should have no Menu Item Controls', function() {
|
||||
ok( 0 === wp.customize.Menus.getMenuControl( socialMenuId ).getMenuItemControls().length, 'empty menus' );
|
||||
QUnit.test( 'empty menus should have no Menu Item Controls', function( assert ) {
|
||||
assert.ok( 0 === wp.customize.Menus.getMenuControl( socialMenuId ).getMenuItemControls().length, 'empty menus' );
|
||||
} );
|
||||
|
||||
test( 'populated menus should have no Menu Item Controls', function() {
|
||||
ok( 0 !== wp.customize.Menus.getMenuControl( primaryMenuId ).getMenuItemControls().length, 'non-empty menus' );
|
||||
QUnit.test( 'populated menus should have no Menu Item Controls', function( assert ) {
|
||||
assert.ok( 0 !== wp.customize.Menus.getMenuControl( primaryMenuId ).getMenuItemControls().length, 'non-empty menus' );
|
||||
} );
|
||||
|
||||
// @todo Add tests for api.Menus.AvailableMenuItemsPanelView
|
||||
// (and api.Menus.AvailableItemCollection, api.Menus.AvailableItemModel).
|
||||
|
||||
test( 'there is a properly configured MenusPanel', function() {
|
||||
QUnit.test( 'there is a properly configured MenusPanel', function( assert ) {
|
||||
var panel, sections;
|
||||
|
||||
panel = api.panel( 'nav_menus' );
|
||||
ok( panel );
|
||||
ok( panel.extended( api.Menus.MenusPanel ) );
|
||||
assert.ok( panel );
|
||||
assert.ok( panel.extended( api.Menus.MenusPanel ) );
|
||||
|
||||
sections = panel.sections();
|
||||
ok( 'menu_locations' === sections[0].id, 'first section is menu_locations' );
|
||||
ok( sections[1].extended( api.Menus.MenuSection ), 'second section is MenuSection' );
|
||||
ok( sections[ sections.length - 1 ].extended( api.Menus.NewMenuSection ), 'last section is NewMenuSection' );
|
||||
assert.ok( 'menu_locations' === sections[0].id, 'first section is menu_locations' );
|
||||
assert.ok( sections[1].extended( api.Menus.MenuSection ), 'second section is MenuSection' );
|
||||
assert.ok( sections[ sections.length - 1 ].extended( api.Menus.NewMenuSection ), 'last section is NewMenuSection' );
|
||||
} );
|
||||
// @todo Add more tests for api.Menus.MenusPanel behaviors.
|
||||
|
||||
test( 'there an expected MenuSection for the primary menu', function() {
|
||||
QUnit.test( 'there an expected MenuSection for the primary menu', function( assert ) {
|
||||
var section, controls, lastControl;
|
||||
|
||||
section = api.section( 'nav_menu[' + primaryMenuId + ']' );
|
||||
ok( section, 'section exists' );
|
||||
ok( section.extended( api.Menus.MenuSection ), 'section is a api.Menus.MenuSection' );
|
||||
ok( section.deferred.initSortables, 'has section.deferred.initSortables' );
|
||||
ok( section.active(), 'section active() is true' );
|
||||
ok( section.active.set( false ).get(), 'section active() cannot be set false' );
|
||||
assert.ok( section, 'section exists' );
|
||||
assert.ok( section.extended( api.Menus.MenuSection ), 'section is a api.Menus.MenuSection' );
|
||||
assert.ok( section.deferred.initSortables, 'has section.deferred.initSortables' );
|
||||
assert.ok( section.active(), 'section active() is true' );
|
||||
assert.ok( section.active.set( false ).get(), 'section active() cannot be set false' );
|
||||
|
||||
controls = section.controls();
|
||||
ok( controls[0].extended( api.Menus.MenuNameControl ), 'first control in menu section is MenuNameControl' );
|
||||
ok( controls[1].extended( api.Menus.MenuItemControl ), 'second control in menu section is MenuItemControl' );
|
||||
assert.ok( controls[0].extended( api.Menus.MenuNameControl ), 'first control in menu section is MenuNameControl' );
|
||||
assert.ok( controls[1].extended( api.Menus.MenuItemControl ), 'second control in menu section is MenuItemControl' );
|
||||
|
||||
lastControl = controls[ controls.length - 1 ];
|
||||
ok( lastControl.extended( api.Control ), 'last control in menu section is a base Control' );
|
||||
ok( lastControl.params.templateId === 'nav-menu-delete-button', 'last control in menu section has a delete-button template' );
|
||||
assert.ok( lastControl.extended( api.Control ), 'last control in menu section is a base Control' );
|
||||
assert.ok( lastControl.params.templateId === 'nav-menu-delete-button', 'last control in menu section has a delete-button template' );
|
||||
} );
|
||||
// @todo Add more tests for api.Menus.MenuSection behaviors.
|
||||
|
||||
test( 'changing a MenuNameControl change the corresponding menu value', function() {
|
||||
QUnit.test( 'changing a MenuNameControl change the corresponding menu value', function( assert ) {
|
||||
var section, control;
|
||||
|
||||
section = api.section( 'nav_menu[' + primaryMenuId + ']' );
|
||||
control = section.controls()[0];
|
||||
ok( control.extended( api.Menus.MenuNameControl ), 'control is a MenuNameControl' );
|
||||
equal( control.setting().name, 'Primary menu' );
|
||||
ok( ! control.setting._dirty );
|
||||
assert.ok( control.extended( api.Menus.MenuNameControl ), 'control is a MenuNameControl' );
|
||||
assert.equal( control.setting().name, 'Primary menu' );
|
||||
assert.ok( ! control.setting._dirty );
|
||||
control.container.find( 'input[type=text]:first' ).val( 'Main menu' ).trigger( 'change' );
|
||||
equal( control.setting().name, 'Main menu' );
|
||||
ok( control.setting._dirty );
|
||||
assert.equal( control.setting().name, 'Main menu' );
|
||||
assert.ok( control.setting._dirty );
|
||||
} );
|
||||
// @todo Add more tests for api.Menus.MenuNameControl
|
||||
|
||||
test( 'manipulating a MenuItemControl works', function() {
|
||||
QUnit.test( 'manipulating a MenuItemControl works', function( assert ) {
|
||||
var section, control, value;
|
||||
section = api.section( 'nav_menu[' + primaryMenuId + ']' );
|
||||
ok( section );
|
||||
assert.ok( section );
|
||||
|
||||
control = section.controls()[1];
|
||||
ok( control.extended( api.Menus.MenuItemControl ), 'control is a MenuItemControl' );
|
||||
assert.ok( control.extended( api.Menus.MenuItemControl ), 'control is a MenuItemControl' );
|
||||
|
||||
control.actuallyEmbed();
|
||||
|
||||
control.container.find( '.edit-menu-item-title' ).val( 'Hello World' ).trigger( 'change' );
|
||||
equal( control.setting().title, 'Hello World' );
|
||||
assert.equal( control.setting().title, 'Hello World' );
|
||||
value = _.clone( control.setting() );
|
||||
value.title = 'Hola Mundo';
|
||||
equal( control.container.find( '.edit-menu-item-title' ).val(), 'Hello World' );
|
||||
equal( value.position, 1 );
|
||||
equal( control.priority(), 1 );
|
||||
assert.equal( control.container.find( '.edit-menu-item-title' ).val(), 'Hello World' );
|
||||
assert.equal( value.position, 1 );
|
||||
assert.equal( control.priority(), 1 );
|
||||
|
||||
// @todo Test control.moveDown().
|
||||
} );
|
||||
@ -118,16 +118,16 @@ jQuery( window ).load( function (){
|
||||
// @todo Add tests for api.Menus.focusMenuItemControl.
|
||||
// @todo Add tests for api.Menus.createNavMenu.
|
||||
|
||||
test( 'api.Menus.getMenuControl() should return the expected control', function() {
|
||||
QUnit.test( 'api.Menus.getMenuControl() should return the expected control', function( assert ) {
|
||||
var control = api.Menus.getMenuControl( primaryMenuId );
|
||||
ok( !! control, 'control is returned' );
|
||||
ok( control.extended( api.Menus.MenuControl ), 'control is a MenuControl' );
|
||||
assert.ok( !! control, 'control is returned' );
|
||||
assert.ok( control.extended( api.Menus.MenuControl ), 'control is a MenuControl' );
|
||||
} );
|
||||
|
||||
test( 'api.Menus.getMenuItemControl() should return the expected control', function() {
|
||||
QUnit.test( 'api.Menus.getMenuItemControl() should return the expected control', function( assert ) {
|
||||
var control = api.Menus.getMenuItemControl( 2000 );
|
||||
ok( !! control, 'control is returned' );
|
||||
ok( control.extended( api.Menus.MenuItemControl ), 'control is a MenuItemControl' );
|
||||
assert.ok( !! control, 'control is returned' );
|
||||
assert.ok( control.extended( api.Menus.MenuItemControl ), 'control is a MenuItemControl' );
|
||||
} );
|
||||
|
||||
} );
|
||||
|
@ -3,25 +3,25 @@ jQuery( window ).load( function() {
|
||||
|
||||
var api = wp.customize, $ = jQuery;
|
||||
|
||||
module( 'Customize Widgets' );
|
||||
QUnit.module( 'Customize Widgets' );
|
||||
|
||||
test( 'fixtures should be present', function() {
|
||||
QUnit.test( 'fixtures should be present', function( assert ) {
|
||||
var widgetControl;
|
||||
ok( api.panel( 'widgets' ) );
|
||||
ok( api.section( 'sidebar-widgets-sidebar-1' ) );
|
||||
assert.ok( api.panel( 'widgets' ) );
|
||||
assert.ok( api.section( 'sidebar-widgets-sidebar-1' ) );
|
||||
widgetControl = api.control( 'widget_search[2]' );
|
||||
ok( widgetControl );
|
||||
ok( api.control( 'sidebars_widgets[sidebar-1]' ) );
|
||||
ok( api( 'widget_search[2]' ) );
|
||||
ok( api( 'sidebars_widgets[sidebar-1]' ) );
|
||||
ok( widgetControl.params.content );
|
||||
ok( widgetControl.params.widget_control );
|
||||
ok( widgetControl.params.widget_content );
|
||||
ok( widgetControl.params.widget_id );
|
||||
ok( widgetControl.params.widget_id_base );
|
||||
assert.ok( widgetControl );
|
||||
assert.ok( api.control( 'sidebars_widgets[sidebar-1]' ) );
|
||||
assert.ok( api( 'widget_search[2]' ) );
|
||||
assert.ok( api( 'sidebars_widgets[sidebar-1]' ) );
|
||||
assert.ok( widgetControl.params.content );
|
||||
assert.ok( widgetControl.params.widget_control );
|
||||
assert.ok( widgetControl.params.widget_content );
|
||||
assert.ok( widgetControl.params.widget_id );
|
||||
assert.ok( widgetControl.params.widget_id_base );
|
||||
});
|
||||
|
||||
test( 'widget contents should embed (with widget-added event) when section and control expand', function() {
|
||||
QUnit.test( 'widget contents should embed (with widget-added event) when section and control expand', function( assert ) {
|
||||
var control, section, widgetAddedEvent = null, widgetControlRootElement = null;
|
||||
control = api.control( 'widget_search[2]' );
|
||||
section = api.section( 'sidebar-widgets-sidebar-1' );
|
||||
@ -31,8 +31,8 @@ jQuery( window ).load( function() {
|
||||
widgetControlRootElement = widgetElement;
|
||||
});
|
||||
|
||||
ok( ! section.expanded() );
|
||||
ok( 0 === control.container.find( '> .widget' ).length );
|
||||
assert.ok( ! section.expanded() );
|
||||
assert.ok( 0 === control.container.find( '> .widget' ).length );
|
||||
|
||||
// Preview sets the active state.
|
||||
section.active.set( true );
|
||||
@ -40,32 +40,32 @@ jQuery( window ).load( function() {
|
||||
api.control( 'sidebars_widgets[sidebar-1]' ).active.set( true );
|
||||
|
||||
section.expand();
|
||||
ok( ! widgetAddedEvent, 'expected widget added event not fired' );
|
||||
ok( 1 === control.container.find( '> .widget' ).length, 'expected there to be one .widget element in the container' );
|
||||
ok( 0 === control.container.find( '.widget-content' ).children().length );
|
||||
assert.ok( ! widgetAddedEvent, 'expected widget added event not fired' );
|
||||
assert.ok( 1 === control.container.find( '> .widget' ).length, 'expected there to be one .widget element in the container' );
|
||||
assert.ok( 0 === control.container.find( '.widget-content' ).children().length );
|
||||
|
||||
control.expand();
|
||||
ok( 1 === control.container.find( '.widget-content' ).children().length );
|
||||
ok( widgetAddedEvent );
|
||||
ok( widgetControlRootElement.is( control.container.find( '> .widget' ) ) );
|
||||
ok( 1 === control.container.find( '.widget-content #widget-search-2-title' ).length );
|
||||
assert.ok( 1 === control.container.find( '.widget-content' ).children().length );
|
||||
assert.ok( widgetAddedEvent );
|
||||
assert.ok( widgetControlRootElement.is( control.container.find( '> .widget' ) ) );
|
||||
assert.ok( 1 === control.container.find( '.widget-content #widget-search-2-title' ).length );
|
||||
|
||||
$( document ).off( 'widget-added' );
|
||||
});
|
||||
|
||||
test( 'widgets panel should have notice', function() {
|
||||
QUnit.test( 'widgets panel should have notice', function( assert ) {
|
||||
var panel = api.panel( 'widgets' );
|
||||
ok( panel.extended( api.Widgets.WidgetsPanel ) );
|
||||
assert.ok( panel.extended( api.Widgets.WidgetsPanel ) );
|
||||
|
||||
panel.deferred.embedded.done( function() {
|
||||
ok( 1 === panel.contentContainer.find( '.no-widget-areas-rendered-notice' ).length );
|
||||
ok( panel.contentContainer.find( '.no-widget-areas-rendered-notice' ).is( ':visible' ) );
|
||||
assert.ok( 1 === panel.contentContainer.find( '.no-widget-areas-rendered-notice' ).length );
|
||||
assert.ok( panel.contentContainer.find( '.no-widget-areas-rendered-notice' ).is( ':visible' ) );
|
||||
api.section( 'sidebar-widgets-sidebar-1' ).active( true );
|
||||
api.control( 'sidebars_widgets[sidebar-1]' ).active( true );
|
||||
api.trigger( 'pane-contents-reflowed' );
|
||||
ok( ! panel.contentContainer.find( '.no-widget-areas-rendered-notice' ).is( ':visible' ) );
|
||||
assert.ok( ! panel.contentContainer.find( '.no-widget-areas-rendered-notice' ).is( ':visible' ) );
|
||||
} );
|
||||
|
||||
expect( 4 );
|
||||
assert.expect( 4 );
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,7 @@
|
||||
eventsFired = 0;
|
||||
|
||||
// Fail if we don't see the expected number of events triggered in 3 seconds.
|
||||
setTimeout( function() {
|
||||
setTimeout( function( assert ) {
|
||||
// QUnit may load this file without running it, in which case `assert`
|
||||
// will never be set to `assertPassed` below.
|
||||
assert && assert.equal(
|
||||
|
@ -1,16 +1,16 @@
|
||||
/* global passwordStrength, wp, jQuery */
|
||||
jQuery( function() {
|
||||
module( 'password-strength-meter' );
|
||||
QUnit.module( 'password-strength-meter' );
|
||||
|
||||
test( 'mismatched passwords should return 5', function() {
|
||||
equal( passwordStrength( 'password1', 'username', 'password2' ), 5, 'mismatched passwords return 5' );
|
||||
QUnit.test( 'mismatched passwords should return 5', function( assert ) {
|
||||
assert.equal( passwordStrength( 'password1', 'username', 'password2' ), 5, 'mismatched passwords return 5' );
|
||||
});
|
||||
|
||||
test( 'passwords shorter than 4 characters should return 0', function() {
|
||||
equal( passwordStrength( 'abc', 'username', 'abc' ), 0, 'short passwords return 0' );
|
||||
QUnit.test( 'passwords shorter than 4 characters should return 0', function( assert ) {
|
||||
assert.equal( passwordStrength( 'abc', 'username', 'abc' ), 0, 'short passwords return 0' );
|
||||
});
|
||||
|
||||
test( 'long complicated passwords should return 4', function() {
|
||||
QUnit.test( 'long complicated passwords should return 4', function( assert ) {
|
||||
var password = function( length ) {
|
||||
var i, n, retVal = '',
|
||||
possibility = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
@ -21,21 +21,21 @@ jQuery( function() {
|
||||
},
|
||||
twofifty = password( 250 );
|
||||
|
||||
equal( passwordStrength( twofifty, 'username', twofifty ), 4, '250 character complicated password returns 4' );
|
||||
assert.equal( passwordStrength( twofifty, 'username', twofifty ), 4, '250 character complicated password returns 4' );
|
||||
});
|
||||
|
||||
test( 'short uncomplicated passwords should return 0', function() {
|
||||
QUnit.test( 'short uncomplicated passwords should return 0', function( assert ) {
|
||||
var letters = 'aaaa',
|
||||
numbers = '1111',
|
||||
password = 'password',
|
||||
uppercase = 'AAAA';
|
||||
equal( passwordStrength( letters, 'username', letters ), 0, 'password of `' + letters + '` returns 0' );
|
||||
equal( passwordStrength( numbers, 'username', numbers ), 0, 'password of `' + numbers + '` returns 0' );
|
||||
equal( passwordStrength( uppercase, 'username', uppercase ), 0, 'password of `' + uppercase + '` returns 0' );
|
||||
equal( passwordStrength( password, 'username', password ), 0, 'password of `' + password + '` returns 0' );
|
||||
assert.equal( passwordStrength( letters, 'username', letters ), 0, 'password of `' + letters + '` returns 0' );
|
||||
assert.equal( passwordStrength( numbers, 'username', numbers ), 0, 'password of `' + numbers + '` returns 0' );
|
||||
assert.equal( passwordStrength( uppercase, 'username', uppercase ), 0, 'password of `' + uppercase + '` returns 0' );
|
||||
assert.equal( passwordStrength( password, 'username', password ), 0, 'password of `' + password + '` returns 0' );
|
||||
});
|
||||
|
||||
test( 'zxcvbn password tests should return the score we expect', function() {
|
||||
QUnit.test( 'zxcvbn password tests should return the score we expect', function( assert ) {
|
||||
var passwords, i;
|
||||
passwords = [
|
||||
{ pw: 'zxcvbn', score: 0 },
|
||||
@ -76,11 +76,11 @@ jQuery( function() {
|
||||
];
|
||||
|
||||
for ( i = 0; i < passwords.length; i++ ) {
|
||||
equal( passwordStrength( passwords[i].pw, 'username', passwords[i].pw ), passwords[i].score, 'password of `' + passwords[i].pw + '` returns ' + passwords[i].score );
|
||||
assert.equal( passwordStrength( passwords[i].pw, 'username', passwords[i].pw ), passwords[i].score, 'password of `' + passwords[i].pw + '` returns ' + passwords[i].score );
|
||||
}
|
||||
});
|
||||
|
||||
test( 'blacklisted words in password should be penalized', function() {
|
||||
QUnit.test( 'blacklisted words in password should be penalized', function( assert ) {
|
||||
var allowedPasswordScore, penalizedPasswordScore,
|
||||
allowedPassword = 'a[janedoefoe]4',
|
||||
penalizedPassword = 'a[johndoefoe]4',
|
||||
@ -89,14 +89,14 @@ jQuery( function() {
|
||||
allowedPasswordScore = passwordStrength( allowedPassword, blacklist, allowedPassword );
|
||||
penalizedPasswordScore = passwordStrength( penalizedPassword, blacklist, penalizedPassword );
|
||||
|
||||
ok( penalizedPasswordScore < allowedPasswordScore, 'Penalized password scored ' + penalizedPasswordScore + '; allowed password scored: ' + allowedPasswordScore );
|
||||
assert.ok( penalizedPasswordScore < allowedPasswordScore, 'Penalized password scored ' + penalizedPasswordScore + '; allowed password scored: ' + allowedPasswordScore );
|
||||
});
|
||||
|
||||
test( 'user input blacklist array should contain expected words', function() {
|
||||
QUnit.test( 'user input blacklist array should contain expected words', function( assert ) {
|
||||
var blacklist = wp.passwordStrength.userInputBlacklist();
|
||||
|
||||
ok( jQuery.isArray( blacklist ), 'blacklist is an array' );
|
||||
ok( jQuery.inArray( 'WordPress', blacklist ) > -1, 'blacklist contains "WordPress" from page title' );
|
||||
ok( jQuery.inArray( 'tests', blacklist ) > -1, 'blacklist contains "tests" from site URL' );
|
||||
assert.ok( jQuery.isArray( blacklist ), 'blacklist is an array' );
|
||||
assert.ok( jQuery.inArray( 'WordPress', blacklist ) > -1, 'blacklist contains "WordPress" from page title' );
|
||||
assert.ok( jQuery.inArray( 'tests', blacklist ) > -1, 'blacklist contains "tests" from site URL' );
|
||||
});
|
||||
});
|
||||
|
@ -6,24 +6,24 @@
|
||||
( function() {
|
||||
'use strict';
|
||||
|
||||
module( 'Gallery Media Widget' );
|
||||
QUnit.module( 'Gallery Media Widget' );
|
||||
|
||||
test( 'gallery widget control', function() {
|
||||
QUnit.test( 'gallery widget control', function( assert ) {
|
||||
var GalleryWidgetControl;
|
||||
equal( typeof wp.mediaWidgets.controlConstructors.media_gallery, 'function', 'wp.mediaWidgets.controlConstructors.media_gallery is a function' );
|
||||
assert.equal( typeof wp.mediaWidgets.controlConstructors.media_gallery, 'function', 'wp.mediaWidgets.controlConstructors.media_gallery is a function' );
|
||||
GalleryWidgetControl = wp.mediaWidgets.controlConstructors.media_gallery;
|
||||
ok( GalleryWidgetControl.prototype instanceof wp.mediaWidgets.MediaWidgetControl, 'wp.mediaWidgets.controlConstructors.media_gallery subclasses wp.mediaWidgets.MediaWidgetControl' );
|
||||
assert.ok( GalleryWidgetControl.prototype instanceof wp.mediaWidgets.MediaWidgetControl, 'wp.mediaWidgets.controlConstructors.media_gallery subclasses wp.mediaWidgets.MediaWidgetControl' );
|
||||
});
|
||||
|
||||
test( 'gallery media model', function() {
|
||||
QUnit.test( 'gallery media model', function( assert ) {
|
||||
var GalleryWidgetModel, galleryWidgetModelInstance;
|
||||
equal( typeof wp.mediaWidgets.modelConstructors.media_gallery, 'function', 'wp.mediaWidgets.modelConstructors.media_gallery is a function' );
|
||||
assert.equal( typeof wp.mediaWidgets.modelConstructors.media_gallery, 'function', 'wp.mediaWidgets.modelConstructors.media_gallery is a function' );
|
||||
GalleryWidgetModel = wp.mediaWidgets.modelConstructors.media_gallery;
|
||||
ok( GalleryWidgetModel.prototype instanceof wp.mediaWidgets.MediaWidgetModel, 'wp.mediaWidgets.modelConstructors.media_gallery subclasses wp.mediaWidgets.MediaWidgetModel' );
|
||||
assert.ok( GalleryWidgetModel.prototype instanceof wp.mediaWidgets.MediaWidgetModel, 'wp.mediaWidgets.modelConstructors.media_gallery subclasses wp.mediaWidgets.MediaWidgetModel' );
|
||||
|
||||
galleryWidgetModelInstance = new GalleryWidgetModel();
|
||||
_.each( galleryWidgetModelInstance.attributes, function( value, key ) {
|
||||
equal( value, GalleryWidgetModel.prototype.schema[ key ][ 'default' ], 'Should properly set default for ' + key );
|
||||
assert.equal( value, GalleryWidgetModel.prototype.schema[ key ][ 'default' ], 'Should properly set default for ' + key );
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -6,14 +6,14 @@
|
||||
( function() {
|
||||
'use strict';
|
||||
|
||||
module( 'Image Media Widget' );
|
||||
QUnit.module( 'Image Media Widget' );
|
||||
|
||||
test( 'image widget control', function() {
|
||||
QUnit.test( 'image widget control', function( assert ) {
|
||||
var ImageWidgetControl, imageWidgetControlInstance, imageWidgetModelInstance, mappedProps, testImageUrl, templateProps;
|
||||
testImageUrl = 'http://s.w.org/style/images/wp-header-logo.png';
|
||||
equal( typeof wp.mediaWidgets.controlConstructors.media_image, 'function', 'wp.mediaWidgets.controlConstructors.media_image is a function' );
|
||||
assert.equal( typeof wp.mediaWidgets.controlConstructors.media_image, 'function', 'wp.mediaWidgets.controlConstructors.media_image is a function' );
|
||||
ImageWidgetControl = wp.mediaWidgets.controlConstructors.media_image;
|
||||
ok( ImageWidgetControl.prototype instanceof wp.mediaWidgets.MediaWidgetControl, 'wp.mediaWidgets.controlConstructors.media_image subclasses wp.mediaWidgets.MediaWidgetControl' );
|
||||
assert.ok( ImageWidgetControl.prototype instanceof wp.mediaWidgets.MediaWidgetControl, 'wp.mediaWidgets.controlConstructors.media_image subclasses wp.mediaWidgets.MediaWidgetControl' );
|
||||
|
||||
imageWidgetModelInstance = new wp.mediaWidgets.modelConstructors.media_image();
|
||||
imageWidgetControlInstance = new ImageWidgetControl({
|
||||
@ -24,35 +24,35 @@
|
||||
|
||||
// Test mapModelToPreviewTemplateProps() when no data is set.
|
||||
templateProps = imageWidgetControlInstance.mapModelToPreviewTemplateProps();
|
||||
equal( templateProps.caption, undefined, 'mapModelToPreviewTemplateProps should not return attributes that are should_preview_update false' );
|
||||
equal( templateProps.attachment_id, 0, 'mapModelToPreviewTemplateProps should return default values' );
|
||||
equal( templateProps.currentFilename, '', 'mapModelToPreviewTemplateProps should return a currentFilename' );
|
||||
assert.equal( templateProps.caption, undefined, 'mapModelToPreviewTemplateProps should not return attributes that are should_preview_update false' );
|
||||
assert.equal( templateProps.attachment_id, 0, 'mapModelToPreviewTemplateProps should return default values' );
|
||||
assert.equal( templateProps.currentFilename, '', 'mapModelToPreviewTemplateProps should return a currentFilename' );
|
||||
|
||||
// Test mapModelToPreviewTemplateProps() when data is set on model.
|
||||
imageWidgetControlInstance.model.set( { url: testImageUrl, alt: 'some alt text', link_type: 'none' } );
|
||||
templateProps = imageWidgetControlInstance.mapModelToPreviewTemplateProps();
|
||||
equal( templateProps.currentFilename, 'wp-header-logo.png', 'mapModelToPreviewTemplateProps should set currentFilename based off of url' );
|
||||
equal( templateProps.url, testImageUrl, 'mapModelToPreviewTemplateProps should return the proper url' );
|
||||
equal( templateProps.alt, 'some alt text', 'mapModelToPreviewTemplateProps should return the proper alt text' );
|
||||
equal( templateProps.link_type, undefined, 'mapModelToPreviewTemplateProps should ignore attributes that are not needed in the preview' );
|
||||
equal( templateProps.error, false, 'mapModelToPreviewTemplateProps should return error state' );
|
||||
assert.equal( templateProps.currentFilename, 'wp-header-logo.png', 'mapModelToPreviewTemplateProps should set currentFilename based off of url' );
|
||||
assert.equal( templateProps.url, testImageUrl, 'mapModelToPreviewTemplateProps should return the proper url' );
|
||||
assert.equal( templateProps.alt, 'some alt text', 'mapModelToPreviewTemplateProps should return the proper alt text' );
|
||||
assert.equal( templateProps.link_type, undefined, 'mapModelToPreviewTemplateProps should ignore attributes that are not needed in the preview' );
|
||||
assert.equal( templateProps.error, false, 'mapModelToPreviewTemplateProps should return error state' );
|
||||
|
||||
// Test mapModelToPreviewTemplateProps() when error is set on model.
|
||||
imageWidgetControlInstance.model.set( 'error', 'missing_attachment' );
|
||||
templateProps = imageWidgetControlInstance.mapModelToPreviewTemplateProps();
|
||||
equal( templateProps.error, 'missing_attachment', 'mapModelToPreviewTemplateProps should return error string' );
|
||||
assert.equal( templateProps.error, 'missing_attachment', 'mapModelToPreviewTemplateProps should return error string' );
|
||||
|
||||
// Reset model.
|
||||
imageWidgetControlInstance.model.set({ error: false, attachment_id: 0, url: null });
|
||||
|
||||
// Test isSelected().
|
||||
equal( imageWidgetControlInstance.isSelected(), false, 'media_image.isSelected() should return false when no media is selected' );
|
||||
assert.equal( imageWidgetControlInstance.isSelected(), false, 'media_image.isSelected() should return false when no media is selected' );
|
||||
imageWidgetControlInstance.model.set({ error: 'missing_attachment', attachment_id: 777 });
|
||||
equal( imageWidgetControlInstance.isSelected(), false, 'media_image.isSelected() should return false when media is selected and error is set' );
|
||||
assert.equal( imageWidgetControlInstance.isSelected(), false, 'media_image.isSelected() should return false when media is selected and error is set' );
|
||||
imageWidgetControlInstance.model.set({ error: false, attachment_id: 777 });
|
||||
equal( imageWidgetControlInstance.isSelected(), true, 'media_image.isSelected() should return true when media is selected and no error exists' );
|
||||
assert.equal( imageWidgetControlInstance.isSelected(), true, 'media_image.isSelected() should return true when media is selected and no error exists' );
|
||||
imageWidgetControlInstance.model.set({ error: false, attachment_id: 0, url: testImageUrl });
|
||||
equal( imageWidgetControlInstance.isSelected(), true, 'media_image.isSelected() should return true when url is set and no error exists' );
|
||||
assert.equal( imageWidgetControlInstance.isSelected(), true, 'media_image.isSelected() should return true when url is set and no error exists' );
|
||||
|
||||
// Reset model.
|
||||
imageWidgetControlInstance.model.set({ error: false, attachment_id: 0, url: null });
|
||||
@ -60,27 +60,27 @@
|
||||
// Test editing of widget title.
|
||||
imageWidgetControlInstance.render();
|
||||
imageWidgetControlInstance.$el.find( '.title' ).val( 'Chicken and Ribs' ).trigger( 'input' );
|
||||
equal( imageWidgetModelInstance.get( 'title' ), 'Chicken and Ribs', 'Changing title should update model title attribute' );
|
||||
assert.equal( imageWidgetModelInstance.get( 'title' ), 'Chicken and Ribs', 'Changing title should update model title attribute' );
|
||||
|
||||
// Test mapMediaToModelProps.
|
||||
mappedProps = imageWidgetControlInstance.mapMediaToModelProps( { link: 'file', url: testImageUrl } );
|
||||
equal( mappedProps.link_url, testImageUrl, 'mapMediaToModelProps should set file link_url according to mediaFrameProps.link' );
|
||||
assert.equal( mappedProps.link_url, testImageUrl, 'mapMediaToModelProps should set file link_url according to mediaFrameProps.link' );
|
||||
mappedProps = imageWidgetControlInstance.mapMediaToModelProps( { link: 'post', postUrl: 'https://wordpress.org/image-2/' } );
|
||||
equal( mappedProps.link_url, 'https://wordpress.org/image-2/', 'mapMediaToModelProps should set file link_url according to mediaFrameProps.link' );
|
||||
assert.equal( mappedProps.link_url, 'https://wordpress.org/image-2/', 'mapMediaToModelProps should set file link_url according to mediaFrameProps.link' );
|
||||
mappedProps = imageWidgetControlInstance.mapMediaToModelProps( { link: 'custom', linkUrl: 'https://wordpress.org' } );
|
||||
equal( mappedProps.link_url, 'https://wordpress.org', 'mapMediaToModelProps should set custom link_url according to mediaFrameProps.linkUrl' );
|
||||
assert.equal( mappedProps.link_url, 'https://wordpress.org', 'mapMediaToModelProps should set custom link_url according to mediaFrameProps.linkUrl' );
|
||||
|
||||
// Test mapModelToMediaFrameProps().
|
||||
imageWidgetControlInstance.model.set({ error: false, url: testImageUrl, 'link_type': 'custom', 'link_url': 'https://wordpress.org', 'size': 'custom', 'width': 100, 'height': 150, 'title': 'widget title', 'image_title': 'title of image' });
|
||||
mappedProps = imageWidgetControlInstance.mapModelToMediaFrameProps( imageWidgetControlInstance.model.toJSON() );
|
||||
equal( mappedProps.linkUrl, 'https://wordpress.org', 'mapModelToMediaFrameProps should set linkUrl from model.link_url' );
|
||||
equal( mappedProps.link, 'custom', 'mapModelToMediaFrameProps should set link from model.link_type' );
|
||||
equal( mappedProps.width, 100, 'mapModelToMediaFrameProps should set width when model.size is custom' );
|
||||
equal( mappedProps.height, 150, 'mapModelToMediaFrameProps should set height when model.size is custom' );
|
||||
equal( mappedProps.title, 'title of image', 'mapModelToMediaFrameProps should set title from model.image_title' );
|
||||
assert.equal( mappedProps.linkUrl, 'https://wordpress.org', 'mapModelToMediaFrameProps should set linkUrl from model.link_url' );
|
||||
assert.equal( mappedProps.link, 'custom', 'mapModelToMediaFrameProps should set link from model.link_type' );
|
||||
assert.equal( mappedProps.width, 100, 'mapModelToMediaFrameProps should set width when model.size is custom' );
|
||||
assert.equal( mappedProps.height, 150, 'mapModelToMediaFrameProps should set height when model.size is custom' );
|
||||
assert.equal( mappedProps.title, 'title of image', 'mapModelToMediaFrameProps should set title from model.image_title' );
|
||||
});
|
||||
|
||||
test( 'image widget control renderPreview', function( assert ) {
|
||||
QUnit.test( 'image widget control renderPreview', function( assert ) {
|
||||
var imageWidgetControlInstance, imageWidgetModelInstance, done;
|
||||
done = assert.async();
|
||||
|
||||
@ -90,27 +90,27 @@
|
||||
syncContainer: jQuery( '<div></div>' ),
|
||||
model: imageWidgetModelInstance
|
||||
});
|
||||
equal( imageWidgetControlInstance.$el.find( 'img' ).length, 0, 'No images should be rendered' );
|
||||
assert.equal( imageWidgetControlInstance.$el.find( 'img' ).length, 0, 'No images should be rendered' );
|
||||
imageWidgetControlInstance.model.set({ error: false, url: 'http://s.w.org/style/images/wp-header-logo.png' });
|
||||
|
||||
// Due to renderPreview being deferred.
|
||||
setTimeout( function() {
|
||||
equal( imageWidgetControlInstance.$el.find( 'img[src="http://s.w.org/style/images/wp-header-logo.png"]' ).length, 1, 'One image should be rendered' );
|
||||
assert.equal( imageWidgetControlInstance.$el.find( 'img[src="http://s.w.org/style/images/wp-header-logo.png"]' ).length, 1, 'One image should be rendered' );
|
||||
done();
|
||||
}, 50 );
|
||||
|
||||
start();
|
||||
done();
|
||||
});
|
||||
|
||||
test( 'image media model', function() {
|
||||
QUnit.test( 'image media model', function( assert ) {
|
||||
var ImageWidgetModel, imageWidgetModelInstance;
|
||||
equal( typeof wp.mediaWidgets.modelConstructors.media_image, 'function', 'wp.mediaWidgets.modelConstructors.media_image is a function' );
|
||||
assert.equal( typeof wp.mediaWidgets.modelConstructors.media_image, 'function', 'wp.mediaWidgets.modelConstructors.media_image is a function' );
|
||||
ImageWidgetModel = wp.mediaWidgets.modelConstructors.media_image;
|
||||
ok( ImageWidgetModel.prototype instanceof wp.mediaWidgets.MediaWidgetModel, 'wp.mediaWidgets.modelConstructors.media_image subclasses wp.mediaWidgets.MediaWidgetModel' );
|
||||
assert.ok( ImageWidgetModel.prototype instanceof wp.mediaWidgets.MediaWidgetModel, 'wp.mediaWidgets.modelConstructors.media_image subclasses wp.mediaWidgets.MediaWidgetModel' );
|
||||
|
||||
imageWidgetModelInstance = new ImageWidgetModel();
|
||||
_.each( imageWidgetModelInstance.attributes, function( value, key ) {
|
||||
equal( value, ImageWidgetModel.prototype.schema[ key ][ 'default' ], 'Should properly set default for ' + key );
|
||||
assert.equal( value, ImageWidgetModel.prototype.schema[ key ][ 'default' ], 'Should properly set default for ' + key );
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -6,14 +6,14 @@
|
||||
( function() {
|
||||
'use strict';
|
||||
|
||||
module( 'Video Media Widget' );
|
||||
QUnit.module( 'Video Media Widget' );
|
||||
|
||||
test( 'video widget control', function() {
|
||||
QUnit.test( 'video widget control', function( assert ) {
|
||||
var VideoWidgetControl, videoWidgetControlInstance, videoWidgetModelInstance, mappedProps, testVideoUrl;
|
||||
testVideoUrl = 'https://videos.files.wordpress.com/AHz0Ca46/wp4-7-vaughan-r8-mastered_hd.mp4';
|
||||
equal( typeof wp.mediaWidgets.controlConstructors.media_video, 'function', 'wp.mediaWidgets.controlConstructors.media_video is a function' );
|
||||
assert.equal( typeof wp.mediaWidgets.controlConstructors.media_video, 'function', 'wp.mediaWidgets.controlConstructors.media_video is a function' );
|
||||
VideoWidgetControl = wp.mediaWidgets.controlConstructors.media_video;
|
||||
ok( VideoWidgetControl.prototype instanceof wp.mediaWidgets.MediaWidgetControl, 'wp.mediaWidgets.controlConstructors.media_video subclasses wp.mediaWidgets.MediaWidgetControl' );
|
||||
assert.ok( VideoWidgetControl.prototype instanceof wp.mediaWidgets.MediaWidgetControl, 'wp.mediaWidgets.controlConstructors.media_video subclasses wp.mediaWidgets.MediaWidgetControl' );
|
||||
|
||||
videoWidgetModelInstance = new wp.mediaWidgets.modelConstructors.media_video();
|
||||
videoWidgetControlInstance = new VideoWidgetControl({
|
||||
@ -25,18 +25,18 @@
|
||||
// Test mapModelToMediaFrameProps().
|
||||
videoWidgetControlInstance.model.set({ error: false, url: testVideoUrl, loop: false, preload: 'meta' });
|
||||
mappedProps = videoWidgetControlInstance.mapModelToMediaFrameProps( videoWidgetControlInstance.model.toJSON() );
|
||||
equal( mappedProps.url, testVideoUrl, 'mapModelToMediaFrameProps should set url' );
|
||||
equal( mappedProps.loop, false, 'mapModelToMediaFrameProps should set loop' );
|
||||
equal( mappedProps.preload, 'meta', 'mapModelToMediaFrameProps should set preload' );
|
||||
assert.equal( mappedProps.url, testVideoUrl, 'mapModelToMediaFrameProps should set url' );
|
||||
assert.equal( mappedProps.loop, false, 'mapModelToMediaFrameProps should set loop' );
|
||||
assert.equal( mappedProps.preload, 'meta', 'mapModelToMediaFrameProps should set preload' );
|
||||
|
||||
// Test mapMediaToModelProps().
|
||||
mappedProps = videoWidgetControlInstance.mapMediaToModelProps( { loop: false, preload: 'meta', url: testVideoUrl, title: 'random movie file title' } );
|
||||
equal( mappedProps.title, undefined, 'mapMediaToModelProps should ignore title inputs' );
|
||||
equal( mappedProps.loop, false, 'mapMediaToModelProps should set loop' );
|
||||
equal( mappedProps.preload, 'meta', 'mapMediaToModelProps should set preload' );
|
||||
assert.equal( mappedProps.title, undefined, 'mapMediaToModelProps should ignore title inputs' );
|
||||
assert.equal( mappedProps.loop, false, 'mapMediaToModelProps should set loop' );
|
||||
assert.equal( mappedProps.preload, 'meta', 'mapMediaToModelProps should set preload' );
|
||||
});
|
||||
|
||||
test( 'video widget control renderPreview', function( assert ) {
|
||||
QUnit.test( 'video widget control renderPreview', function( assert ) {
|
||||
var videoWidgetControlInstance, videoWidgetModelInstance, done;
|
||||
done = assert.async();
|
||||
|
||||
@ -46,26 +46,27 @@
|
||||
syncContainer: jQuery( '<div></div>' ),
|
||||
model: videoWidgetModelInstance
|
||||
});
|
||||
equal( videoWidgetControlInstance.$el.find( 'a' ).length, 0, 'No video links should be rendered' );
|
||||
assert.equal( videoWidgetControlInstance.$el.find( 'a' ).length, 0, 'No video links should be rendered' );
|
||||
videoWidgetControlInstance.model.set({ error: false, url: 'https://videos.files.wordpress.com/AHz0Ca46/wp4-7-vaughan-r8-mastered_hd.mp4' });
|
||||
|
||||
// Due to renderPreview being deferred.
|
||||
setTimeout( function() {
|
||||
equal( videoWidgetControlInstance.$el.find( 'a[href="https://videos.files.wordpress.com/AHz0Ca46/wp4-7-vaughan-r8-mastered_hd.mp4"]' ).length, 1, 'One video link should be rendered' );
|
||||
assert.equal( videoWidgetControlInstance.$el.find( 'a[href="https://videos.files.wordpress.com/AHz0Ca46/wp4-7-vaughan-r8-mastered_hd.mp4"]' ).length, 1, 'One video link should be rendered' );
|
||||
done();
|
||||
}, 50 );
|
||||
start();
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test( 'video media model', function() {
|
||||
QUnit.test( 'video media model', function( assert ) {
|
||||
var VideoWidgetModel, videoWidgetModelInstance;
|
||||
equal( typeof wp.mediaWidgets.modelConstructors.media_video, 'function', 'wp.mediaWidgets.modelConstructors.media_video is a function' );
|
||||
assert.equal( typeof wp.mediaWidgets.modelConstructors.media_video, 'function', 'wp.mediaWidgets.modelConstructors.media_video is a function' );
|
||||
VideoWidgetModel = wp.mediaWidgets.modelConstructors.media_video;
|
||||
ok( VideoWidgetModel.prototype instanceof wp.mediaWidgets.MediaWidgetModel, 'wp.mediaWidgets.modelConstructors.media_video subclasses wp.mediaWidgets.MediaWidgetModel' );
|
||||
assert.ok( VideoWidgetModel.prototype instanceof wp.mediaWidgets.MediaWidgetModel, 'wp.mediaWidgets.modelConstructors.media_video subclasses wp.mediaWidgets.MediaWidgetModel' );
|
||||
|
||||
videoWidgetModelInstance = new VideoWidgetModel();
|
||||
_.each( videoWidgetModelInstance.attributes, function( value, key ) {
|
||||
equal( value, VideoWidgetModel.prototype.schema[ key ][ 'default' ], 'Should properly set default for ' + key );
|
||||
assert.equal( value, VideoWidgetModel.prototype.schema[ key ][ 'default' ], 'Should properly set default for ' + key );
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -2,44 +2,44 @@
|
||||
/* jshint qunit: true */
|
||||
/* eslint-env qunit */
|
||||
|
||||
(function() {
|
||||
( function() {
|
||||
'use strict';
|
||||
|
||||
module( 'Media Widgets' );
|
||||
QUnit.module( 'Media Widgets' );
|
||||
|
||||
test( 'namespace', function() {
|
||||
equal( typeof wp.mediaWidgets, 'object', 'wp.mediaWidgets is an object' );
|
||||
equal( typeof wp.mediaWidgets.controlConstructors, 'object', 'wp.mediaWidgets.controlConstructors is an object' );
|
||||
equal( typeof wp.mediaWidgets.modelConstructors, 'object', 'wp.mediaWidgets.modelConstructors is an object' );
|
||||
equal( typeof wp.mediaWidgets.widgetControls, 'object', 'wp.mediaWidgets.widgetControls is an object' );
|
||||
equal( typeof wp.mediaWidgets.handleWidgetAdded, 'function', 'wp.mediaWidgets.handleWidgetAdded is an function' );
|
||||
equal( typeof wp.mediaWidgets.handleWidgetUpdated, 'function', 'wp.mediaWidgets.handleWidgetUpdated is an function' );
|
||||
equal( typeof wp.mediaWidgets.init, 'function', 'wp.mediaWidgets.init is an function' );
|
||||
QUnit.test( 'namespace', function( assert ) {
|
||||
assert.equal( typeof wp.mediaWidgets, 'object', 'wp.mediaWidgets is an object' );
|
||||
assert.equal( typeof wp.mediaWidgets.controlConstructors, 'object', 'wp.mediaWidgets.controlConstructors is an object' );
|
||||
assert.equal( typeof wp.mediaWidgets.modelConstructors, 'object', 'wp.mediaWidgets.modelConstructors is an object' );
|
||||
assert.equal( typeof wp.mediaWidgets.widgetControls, 'object', 'wp.mediaWidgets.widgetControls is an object' );
|
||||
assert.equal( typeof wp.mediaWidgets.handleWidgetAdded, 'function', 'wp.mediaWidgets.handleWidgetAdded is an function' );
|
||||
assert.equal( typeof wp.mediaWidgets.handleWidgetUpdated, 'function', 'wp.mediaWidgets.handleWidgetUpdated is an function' );
|
||||
assert.equal( typeof wp.mediaWidgets.init, 'function', 'wp.mediaWidgets.init is an function' );
|
||||
});
|
||||
|
||||
test( 'media widget control', function() {
|
||||
equal( typeof wp.mediaWidgets.MediaWidgetControl, 'function', 'wp.mediaWidgets.MediaWidgetControl' );
|
||||
ok( wp.mediaWidgets.MediaWidgetControl.prototype instanceof Backbone.View, 'wp.mediaWidgets.MediaWidgetControl subclasses Backbone.View' );
|
||||
QUnit.test( 'media widget control', function( assert ) {
|
||||
assert.equal( typeof wp.mediaWidgets.MediaWidgetControl, 'function', 'wp.mediaWidgets.MediaWidgetControl' );
|
||||
assert.ok( wp.mediaWidgets.MediaWidgetControl.prototype instanceof Backbone.View, 'wp.mediaWidgets.MediaWidgetControl subclasses Backbone.View' );
|
||||
});
|
||||
|
||||
test( 'media widget model', function() {
|
||||
QUnit.test( 'media widget model', function( assert ) {
|
||||
var widgetModelInstance;
|
||||
equal( typeof wp.mediaWidgets.MediaWidgetModel, 'function', 'wp.mediaWidgets.MediaWidgetModel is a function' );
|
||||
ok( wp.mediaWidgets.MediaWidgetModel.prototype instanceof Backbone.Model, 'wp.mediaWidgets.MediaWidgetModel subclasses Backbone.Model' );
|
||||
assert.equal( typeof wp.mediaWidgets.MediaWidgetModel, 'function', 'wp.mediaWidgets.MediaWidgetModel is a function' );
|
||||
assert.ok( wp.mediaWidgets.MediaWidgetModel.prototype instanceof Backbone.Model, 'wp.mediaWidgets.MediaWidgetModel subclasses Backbone.Model' );
|
||||
|
||||
widgetModelInstance = new wp.mediaWidgets.MediaWidgetModel();
|
||||
equal( widgetModelInstance.get( 'title' ), '', 'wp.mediaWidgets.MediaWidgetModel defaults title to empty string' );
|
||||
equal( widgetModelInstance.get( 'attachment_id' ), 0, 'wp.mediaWidgets.MediaWidgetModel defaults attachment_id to 0' );
|
||||
equal( widgetModelInstance.get( 'url' ), 0, 'wp.mediaWidgets.MediaWidgetModel defaults url to empty string' );
|
||||
assert.equal( widgetModelInstance.get( 'title' ), '', 'wp.mediaWidgets.MediaWidgetModel defaults title to empty string' );
|
||||
assert.equal( widgetModelInstance.get( 'attachment_id' ), 0, 'wp.mediaWidgets.MediaWidgetModel defaults attachment_id to 0' );
|
||||
assert.equal( widgetModelInstance.get( 'url' ), 0, 'wp.mediaWidgets.MediaWidgetModel defaults url to empty string' );
|
||||
|
||||
widgetModelInstance.set({
|
||||
title: 'chicken and ribs',
|
||||
attachment_id: '1',
|
||||
url: 'https://wordpress.org'
|
||||
});
|
||||
equal( widgetModelInstance.get( 'title' ), 'chicken and ribs', 'wp.mediaWidgets.MediaWidgetModel properly sets the title attribute' );
|
||||
equal( widgetModelInstance.get( 'url' ), 'https://wordpress.org', 'wp.mediaWidgets.MediaWidgetModel properly sets the url attribute' );
|
||||
equal( widgetModelInstance.get( 'attachment_id' ), 1, 'wp.mediaWidgets.MediaWidgetModel properly sets and casts the attachment_id attribute' );
|
||||
assert.equal( widgetModelInstance.get( 'title' ), 'chicken and ribs', 'wp.mediaWidgets.MediaWidgetModel properly sets the title attribute' );
|
||||
assert.equal( widgetModelInstance.get( 'url' ), 'https://wordpress.org', 'wp.mediaWidgets.MediaWidgetModel properly sets the url attribute' );
|
||||
assert.equal( widgetModelInstance.get( 'attachment_id' ), 1, 'wp.mediaWidgets.MediaWidgetModel properly sets and casts the attachment_id attribute' );
|
||||
});
|
||||
|
||||
})();
|
||||
|
@ -1,167 +1,167 @@
|
||||
/* global wp, jQuery */
|
||||
jQuery( function() {
|
||||
module( 'shortcode' );
|
||||
QUnit.module( 'shortcode' );
|
||||
|
||||
test( 'next() should find the shortcode', function() {
|
||||
QUnit.test( 'next() should find the shortcode', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Basic.
|
||||
result = wp.shortcode.next( 'foo', 'this has the [foo] shortcode' );
|
||||
equal( result.index, 13, 'foo shortcode found at index 13' );
|
||||
assert.equal( result.index, 13, 'foo shortcode found at index 13' );
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [foo param="foo"] shortcode' );
|
||||
equal( result.index, 13, 'foo shortcode with params found at index 13' );
|
||||
assert.equal( result.index, 13, 'foo shortcode with params found at index 13' );
|
||||
});
|
||||
|
||||
test( 'next() should not find shortcodes that are not there', function() {
|
||||
QUnit.test( 'next() should not find shortcodes that are not there', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Not found.
|
||||
result = wp.shortcode.next( 'bar', 'this has the [foo] shortcode' );
|
||||
equal( result, undefined, 'bar shortcode not found' );
|
||||
assert.equal( result, undefined, 'bar shortcode not found' );
|
||||
|
||||
result = wp.shortcode.next( 'bar', 'this has the [foo param="bar"] shortcode' );
|
||||
equal( result, undefined, 'bar shortcode not found with params' );
|
||||
assert.equal( result, undefined, 'bar shortcode not found with params' );
|
||||
});
|
||||
|
||||
test( 'next() should find the shortcode when told to start looking beyond the start of the string', function() {
|
||||
QUnit.test( 'next() should find the shortcode when told to start looking beyond the start of the string', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Starting at indices.
|
||||
result = wp.shortcode.next( 'foo', 'this has the [foo] shortcode', 12 );
|
||||
equal( result.index, 13, 'foo shortcode found before index 13' );
|
||||
assert.equal( result.index, 13, 'foo shortcode found before index 13' );
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [foo] shortcode', 13 );
|
||||
equal( result.index, 13, 'foo shortcode found at index 13' );
|
||||
assert.equal( result.index, 13, 'foo shortcode found at index 13' );
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [foo] shortcode', 14 );
|
||||
equal( result, undefined, 'foo shortcode not found after index 13' );
|
||||
assert.equal( result, undefined, 'foo shortcode not found after index 13' );
|
||||
});
|
||||
|
||||
test( 'next() should find the second instances of the shortcode when the starting indice is after the start of the first one', function() {
|
||||
QUnit.test( 'next() should find the second instances of the shortcode when the starting indice is after the start of the first one', function( assert ) {
|
||||
var result;
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [foo] shortcode [foo] twice', 14 );
|
||||
equal( result.index, 29, 'foo shortcode found the second foo at index 29' );
|
||||
assert.equal( result.index, 29, 'foo shortcode found the second foo at index 29' );
|
||||
});
|
||||
|
||||
|
||||
test( 'next() should not find escaped shortcodes', function() {
|
||||
QUnit.test( 'next() should not find escaped shortcodes', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Escaped.
|
||||
result = wp.shortcode.next( 'foo', 'this has the [[foo]] shortcode' );
|
||||
equal( result, undefined, 'foo shortcode not found when escaped' );
|
||||
assert.equal( result, undefined, 'foo shortcode not found when escaped' );
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [[foo param="foo"]] shortcode' );
|
||||
equal( result, undefined, 'foo shortcode not found when escaped with params' );
|
||||
assert.equal( result, undefined, 'foo shortcode not found when escaped with params' );
|
||||
});
|
||||
|
||||
test( 'next() should find shortcodes that are incorrectly escaped by newlines', function() {
|
||||
QUnit.test( 'next() should find shortcodes that are incorrectly escaped by newlines', function( assert ) {
|
||||
var result;
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [\n[foo]] shortcode' );
|
||||
equal( result.index, 15, 'shortcode found when incorrectly escaping the start of it' );
|
||||
assert.equal( result.index, 15, 'shortcode found when incorrectly escaping the start of it' );
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [[foo]\n] shortcode' );
|
||||
equal( result.index, 14, 'shortcode found when incorrectly escaping the end of it' );
|
||||
assert.equal( result.index, 14, 'shortcode found when incorrectly escaping the end of it' );
|
||||
});
|
||||
|
||||
test( 'next() should still work when there are not equal ammounts of square brackets', function() {
|
||||
QUnit.test( 'next() should still work when there are not equal ammounts of square brackets', function( assert ) {
|
||||
var result;
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [[foo] shortcode' );
|
||||
equal( result.index, 14, 'shortcode found when there are offset square brackets' );
|
||||
assert.equal( result.index, 14, 'shortcode found when there are offset square brackets' );
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [foo]] shortcode' );
|
||||
equal( result.index, 13, 'shortcode found when there are offset square brackets' );
|
||||
assert.equal( result.index, 13, 'shortcode found when there are offset square brackets' );
|
||||
});
|
||||
|
||||
test( 'next() should find the second instances of the shortcode when the first one is escaped', function() {
|
||||
QUnit.test( 'next() should find the second instances of the shortcode when the first one is escaped', function( assert ) {
|
||||
var result;
|
||||
|
||||
|
||||
result = wp.shortcode.next( 'foo', 'this has the [[foo]] shortcode [foo] twice' );
|
||||
equal( result.index, 31, 'foo shortcode found the non-escaped foo at index 31' );
|
||||
assert.equal( result.index, 31, 'foo shortcode found the non-escaped foo at index 31' );
|
||||
});
|
||||
|
||||
test( 'next() should not find shortcodes that are not full matches', function() {
|
||||
QUnit.test( 'next() should not find shortcodes that are not full matches', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Stubs.
|
||||
result = wp.shortcode.next( 'foo', 'this has the [foobar] shortcode' );
|
||||
equal( result, undefined, 'stub does not trigger match' );
|
||||
assert.equal( result, undefined, 'stub does not trigger match' );
|
||||
|
||||
result = wp.shortcode.next( 'foobar', 'this has the [foo] shortcode' );
|
||||
equal( result, undefined, 'stub does not trigger match' );
|
||||
assert.equal( result, undefined, 'stub does not trigger match' );
|
||||
});
|
||||
|
||||
test( 'replace() should replace the shortcode', function() {
|
||||
QUnit.test( 'replace() should replace the shortcode', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Basic.
|
||||
result = wp.shortcode.replace( 'foo', 'this has the [foo] shortcode', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the bar shortcode', 'foo replaced with bar' );
|
||||
assert.equal( result, 'this has the bar shortcode', 'foo replaced with bar' );
|
||||
|
||||
result = wp.shortcode.replace( 'foo', 'this has the [foo param="foo"] shortcode', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the bar shortcode', 'foo and params replaced with bar' );
|
||||
assert.equal( result, 'this has the bar shortcode', 'foo and params replaced with bar' );
|
||||
});
|
||||
|
||||
test( 'replace() should not replace the shortcode when it does not match', function() {
|
||||
QUnit.test( 'replace() should not replace the shortcode when it does not match', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Not found.
|
||||
result = wp.shortcode.replace( 'bar', 'this has the [foo] shortcode', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the [foo] shortcode', 'bar not found' );
|
||||
assert.equal( result, 'this has the [foo] shortcode', 'bar not found' );
|
||||
|
||||
result = wp.shortcode.replace( 'bar', 'this has the [foo param="bar"] shortcode', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the [foo param="bar"] shortcode', 'bar not found with params' );
|
||||
assert.equal( result, 'this has the [foo param="bar"] shortcode', 'bar not found with params' );
|
||||
});
|
||||
|
||||
test( 'replace() should replace the shortcode in all instances of its use', function() {
|
||||
QUnit.test( 'replace() should replace the shortcode in all instances of its use', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Multiple instances.
|
||||
result = wp.shortcode.replace( 'foo', 'this has the [foo] shortcode [foo] twice', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the bar shortcode bar twice', 'foo replaced with bar twice' );
|
||||
assert.equal( result, 'this has the bar shortcode bar twice', 'foo replaced with bar twice' );
|
||||
|
||||
result = wp.shortcode.replace( 'foo', 'this has the [foo param="foo"] shortcode [foo] twice', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the bar shortcode bar twice', 'foo and params replaced with bar twice' );
|
||||
assert.equal( result, 'this has the bar shortcode bar twice', 'foo and params replaced with bar twice' );
|
||||
});
|
||||
|
||||
test( 'replace() should not replace the escaped shortcodes', function() {
|
||||
QUnit.test( 'replace() should not replace the escaped shortcodes', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Escaped.
|
||||
result = wp.shortcode.replace( 'foo', 'this has the [[foo]] shortcode', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the [[foo]] shortcode', 'escaped foo not replaced' );
|
||||
assert.equal( result, 'this has the [[foo]] shortcode', 'escaped foo not replaced' );
|
||||
|
||||
result = wp.shortcode.replace( 'foo', 'this has the [[foo param="bar"]] shortcode', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the [[foo param="bar"]] shortcode', 'escaped foo with params not replaced' );
|
||||
assert.equal( result, 'this has the [[foo param="bar"]] shortcode', 'escaped foo with params not replaced' );
|
||||
|
||||
result = wp.shortcode.replace( 'foo', 'this [foo] has the [[foo param="bar"]] shortcode escaped', shortcodeReplaceCallback );
|
||||
equal( result, 'this bar has the [[foo param="bar"]] shortcode escaped', 'escaped foo with params not replaced but unescaped foo replaced' );
|
||||
assert.equal( result, 'this bar has the [[foo param="bar"]] shortcode escaped', 'escaped foo with params not replaced but unescaped foo replaced' );
|
||||
});
|
||||
|
||||
test( 'replace() should replace improperly escaped shortcodes that include newlines', function() {
|
||||
QUnit.test( 'replace() should replace improperly escaped shortcodes that include newlines', function( assert ) {
|
||||
var result;
|
||||
|
||||
result = wp.shortcode.replace( 'foo', 'this [foo] has the [[foo param="bar"]\n] shortcode ', shortcodeReplaceCallback );
|
||||
equal( result, 'this bar has the [bar\n] shortcode ', 'escaping with newlines should not actually escape the content' );
|
||||
assert.equal( result, 'this bar has the [bar\n] shortcode ', 'escaping with newlines should not actually escape the content' );
|
||||
|
||||
result = wp.shortcode.replace( 'foo', 'this [foo] has the [\n[foo param="bar"]] shortcode ', shortcodeReplaceCallback );
|
||||
equal( result, 'this bar has the [\nbar] shortcode ', 'escaping with newlines should not actually escape the content' );
|
||||
assert.equal( result, 'this bar has the [\nbar] shortcode ', 'escaping with newlines should not actually escape the content' );
|
||||
});
|
||||
|
||||
test( 'replace() should not replace the shortcode when it is an incomplete match', function() {
|
||||
QUnit.test( 'replace() should not replace the shortcode when it is an incomplete match', function( assert ) {
|
||||
var result;
|
||||
|
||||
// Stubs.
|
||||
result = wp.shortcode.replace( 'foo', 'this has the [foobar] shortcode', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the [foobar] shortcode', 'stub not replaced' );
|
||||
assert.equal( result, 'this has the [foobar] shortcode', 'stub not replaced' );
|
||||
|
||||
result = wp.shortcode.replace( 'foobar', 'this has the [foo] shortcode', shortcodeReplaceCallback );
|
||||
equal( result, 'this has the [foo] shortcode', 'stub not replaced' );
|
||||
assert.equal( result, 'this has the [foo] shortcode', 'stub not replaced' );
|
||||
});
|
||||
|
||||
/**
|
||||
@ -171,7 +171,7 @@ jQuery( function() {
|
||||
return 'bar';
|
||||
}
|
||||
|
||||
test( 'attrs() should return named attributes created with single, double, and no quotes', function() {
|
||||
QUnit.test( 'attrs() should return named attributes created with single, double, and no quotes', function( assert ) {
|
||||
var expected = {
|
||||
'named': {
|
||||
'param': 'foo',
|
||||
@ -180,42 +180,42 @@ jQuery( function() {
|
||||
}, 'numeric' : []
|
||||
};
|
||||
|
||||
deepEqual( wp.shortcode.attrs('param="foo" another=\'bar\' andagain=baz'), expected, 'attr parsed all three named types');
|
||||
assert.deepEqual( wp.shortcode.attrs('param="foo" another=\'bar\' andagain=baz'), expected, 'attr parsed all three named types');
|
||||
});
|
||||
|
||||
test( 'attrs() should return numeric attributes in the order they are used', function() {
|
||||
QUnit.test( 'attrs() should return numeric attributes in the order they are used', function( assert ) {
|
||||
var expected = {
|
||||
'named': {}, 'numeric' : ['foo', 'bar', 'baz']
|
||||
};
|
||||
|
||||
deepEqual( wp.shortcode.attrs('foo bar baz'), expected, 'attr parsed numeric attributes');
|
||||
assert.deepEqual( wp.shortcode.attrs('foo bar baz'), expected, 'attr parsed numeric attributes');
|
||||
});
|
||||
|
||||
test( 'attrs() should return numeric attributes in the order they are used when they have named attributes in between', function() {
|
||||
QUnit.test( 'attrs() should return numeric attributes in the order they are used when they have named attributes in between', function( assert ) {
|
||||
var expected = {
|
||||
'named': { 'not': 'a blocker' }, 'numeric' : ['foo', 'bar', 'baz']
|
||||
};
|
||||
|
||||
deepEqual( wp.shortcode.attrs('foo not="a blocker" bar baz'), expected, 'attr parsed numeric attributes');
|
||||
assert.deepEqual( wp.shortcode.attrs('foo not="a blocker" bar baz'), expected, 'attr parsed numeric attributes');
|
||||
});
|
||||
|
||||
test( 'attrs() should return numeric attributes created with single, double, and no quotes', function() {
|
||||
QUnit.test( 'attrs() should return numeric attributes created with single, double, and no quotes', function( assert ) {
|
||||
var expected = {
|
||||
'named': {}, 'numeric' : ['foo', 'bar', 'baz']
|
||||
};
|
||||
|
||||
deepEqual( wp.shortcode.attrs('foo "bar" \'baz\''), expected, 'attr parsed numeric attributes');
|
||||
assert.deepEqual( wp.shortcode.attrs('foo "bar" \'baz\''), expected, 'attr parsed numeric attributes');
|
||||
});
|
||||
|
||||
test( 'attrs() should return mixed attributes created with single, double, and no quotes', function() {
|
||||
QUnit.test( 'attrs() should return mixed attributes created with single, double, and no quotes', function( assert ) {
|
||||
var expected = {
|
||||
'named': { a: 'foo', b: 'bar', c: 'baz' }, 'numeric' : ['foo', 'bar', 'baz']
|
||||
};
|
||||
|
||||
deepEqual( wp.shortcode.attrs('a="foo" b=\'bar\' c=baz foo "bar" \'baz\''), expected, 'attr parsed numeric attributes');
|
||||
assert.deepEqual( wp.shortcode.attrs('a="foo" b=\'bar\' c=baz foo "bar" \'baz\''), expected, 'attr parsed numeric attributes');
|
||||
});
|
||||
|
||||
test( 'string() should accept attrs in any order', function() {
|
||||
QUnit.test( 'string() should accept attrs in any order', function( assert ) {
|
||||
var expected = '[short abc123 foo="bar"]';
|
||||
var result;
|
||||
|
||||
@ -227,7 +227,7 @@ jQuery( function() {
|
||||
numeric : [ 'abc123' ]
|
||||
}
|
||||
});
|
||||
deepEqual( result, expected, 'attributes are accepted in any order' );
|
||||
assert.deepEqual( result, expected, 'attributes are accepted in any order' );
|
||||
|
||||
result = wp.shortcode.string({
|
||||
tag : 'short',
|
||||
@ -237,6 +237,6 @@ jQuery( function() {
|
||||
named : { foo : 'bar' }
|
||||
}
|
||||
});
|
||||
deepEqual( result, expected, 'attributes are accepted in any order' );
|
||||
assert.deepEqual( result, expected, 'attributes are accepted in any order' );
|
||||
});
|
||||
});
|
||||
|
@ -81,7 +81,7 @@
|
||||
|
||||
// Ref: http://www.w3.org/TR/html5/obsolete.html, http://developers.whatwg.org/obsolete.html
|
||||
|
||||
QUnit.test('HTML elements non-conforming to HTML 5.0', function() {
|
||||
QUnit.test('HTML elements non-conforming to HTML 5.0', function( assert ) {
|
||||
var testString;
|
||||
|
||||
/*
|
||||
@ -109,97 +109,97 @@
|
||||
The rest are still supported in TinyMCE but "...must not be used by authors".
|
||||
*/
|
||||
|
||||
expect(6);
|
||||
assert.expect(6);
|
||||
|
||||
text = 'acronym';
|
||||
testString = '<p><acronym title="www">WWW</acronym></p>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'strike, converted to span';
|
||||
editor.setContent( '<strike>test</strike>' );
|
||||
equal( editor.getContent(), '<p><span style="text-decoration: line-through;">test</span></p>', text );
|
||||
assert.equal( editor.getContent(), '<p><span style="text-decoration: line-through;">test</span></p>', text );
|
||||
|
||||
text = 'big';
|
||||
testString = '<p><big>test</big></p>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'center';
|
||||
testString = '<center>test</center>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'font, converted to span';
|
||||
editor.setContent( '<p><font size="4">test</font></p>' );
|
||||
equal( editor.getContent(), '<p><span style="font-size: large;">test</span></p>', text );
|
||||
assert.equal( editor.getContent(), '<p><span style="font-size: large;">test</span></p>', text );
|
||||
|
||||
text = 'tt';
|
||||
testString = '<p><tt>test</tt></p>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
});
|
||||
|
||||
QUnit.test('Obsolete (but still conforming) HTML attributes', function() {
|
||||
QUnit.test('Obsolete (but still conforming) HTML attributes', function( assert ) {
|
||||
var testString;
|
||||
|
||||
expect(3);
|
||||
assert.expect(3);
|
||||
|
||||
text = 'border on <img>';
|
||||
testString = '<p><img src="../../test.gif" alt="" border="5" /></p>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'Old style anchors';
|
||||
testString = '<p><a name="test"></a></p>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'maxlength, size on input type="number"';
|
||||
testString = '<p><input maxlength="5" size="10" type="number" value="" /></p>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { input: 'maxlength size' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { input: 'maxlength size' } ), text );
|
||||
});
|
||||
|
||||
QUnit.test('Obsolete attributes in HTML 5.0', function() {
|
||||
QUnit.test('Obsolete attributes in HTML 5.0', function( assert ) {
|
||||
var testString, text;
|
||||
|
||||
expect(22);
|
||||
assert.expect(22);
|
||||
|
||||
text = 'charset, rev, shape, coords on <a> elements';
|
||||
testString = '<p><a href="javascript;:" charset="en" rev="made" shape="rect" coords="5,5">test</a></p>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { a: 'charset rev shape coords' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { a: 'charset rev shape coords' } ), text );
|
||||
|
||||
text = 'name, align, hspace, vspace on img elements';
|
||||
testString = '<p><img src="../../test.gif" alt="" name="test" align="left" hspace="5" vspace="5" /></p>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { img: 'name align hspace vspace' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { img: 'name align hspace vspace' } ), text );
|
||||
|
||||
text = 'name, align, hspace, vspace, on embed elements';
|
||||
testString = '<p><embed width="100" height="100" src="test.swf" vspace="5" hspace="5" align="left" name="test"></embed></p>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { embed: 'name align hspace vspace' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { embed: 'name align hspace vspace' } ), text );
|
||||
|
||||
text = 'archive, classid, code, codebase, codetype, declare, standby on object elements';
|
||||
testString = '<p><object width="100" height="100" classid="clsid" codebase="clsid" standby="standby" codetype="1" code="1" archive="1" declare="declare"></object></p>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { object: 'archive classid code codebase codetype declare standby' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { object: 'archive classid code codebase codetype declare standby' } ), text );
|
||||
|
||||
text = 'type, valuetype on param elements';
|
||||
testString = '<p><object width="100" height="100"><param type="" valuetype="" /></object></p>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { param: 'type valuetype' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { param: 'type valuetype' } ), text );
|
||||
|
||||
text = 'align, bgcolor, border, cellpadding, cellspacing, frame, rules, summary, width on table elements';
|
||||
testString = '<table border="1" summary="" width="100" frame="" rules="" cellspacing="5" cellpadding="5" align="left" bgcolor="blue"><tbody><tr><td>test</td></tr></tbody></table>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { table: 'align bgcolor border cellpadding cellspacing frame rules summary width' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { table: 'align bgcolor border cellpadding cellspacing frame rules summary width' } ), text );
|
||||
|
||||
text = 'align, char, charoff, valign on tbody, thead, and tfoot elements';
|
||||
testString = '<table><thead align="left" char="" charoff="" valign="top"></thead><tfoot align="left" char="" charoff="" valign="top"></tfoot><tbody align="left" char="" charoff="" valign="top"><tr><th>test</th><td>test</td></tr></tbody></table>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), {
|
||||
assert.ok( hasAttr( editor.getContent(), {
|
||||
thead: 'align char charoff valign',
|
||||
tfoot: 'align char charoff valign',
|
||||
tbody: 'align char charoff valign'
|
||||
@ -208,7 +208,7 @@
|
||||
text = 'axis, align, bgcolor, char, charoff, height, nowrap, valign, width on td and th elements, scope on td elements';
|
||||
testString = '<table><tbody><tr><th axis="" align="left" char="" charoff="" valign="top" nowrap="nowrap" bgcolor="blue" width="100" height="10">test</th><td axis="" align="left" char="" charoff="" valign="top" nowrap="nowrap" bgcolor="blue" width="100" height="10" scope="">test</td></tr></tbody></table>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), {
|
||||
assert.ok( hasAttr( editor.getContent(), {
|
||||
th: 'axis align bgcolor char charoff height nowrap valign width',
|
||||
td: 'axis align bgcolor char charoff height nowrap valign width scope'
|
||||
} ), text );
|
||||
@ -216,72 +216,72 @@
|
||||
text = 'align, bgcolor, char, charoff, valign on tr elements';
|
||||
testString = '<table><tbody><tr align="left" char="" charoff="" valign="top" bgcolor="blue"><td>test</td></tr></tbody></table>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { tr: 'align bgcolor char charoff valign' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { tr: 'align bgcolor char charoff valign' } ), text );
|
||||
|
||||
text = 'clear on br elements';
|
||||
testString = '<p>test<br clear="all" />test</p>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'align on caption elements';
|
||||
testString = '<table><caption align="left">test</caption><tbody><tr><td>test</td></tr></tbody></table>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'align, char, charoff, valign, width on col elements';
|
||||
testString = '<table><colgroup><col width="100" align="left" char="a" charoff="1" valign="top" /><col /></colgroup><tbody><tr><td>test</td><td>test</td></tr></tbody></table>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { col: 'align char charoff valign width' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { col: 'align char charoff valign width' } ), text );
|
||||
|
||||
text = 'align on div, h1—h6, input, legend, p elements';
|
||||
testString = '<div align="left">1</div><h3 align="left">1</h3><p align="left">1</p><form><fieldset><legend align="left">test</legend><input type="text" align="left" /></fieldset></form>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'compact on dl elements';
|
||||
testString = '<dl compact="compact"><dd>1</dd></dl>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'align, hspace, vspace on embed elements';
|
||||
testString = '<p><embed width="100" height="100" vspace="5" hspace="5" align="left"></embed></p>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { embed: 'align hspace vspace' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { embed: 'align hspace vspace' } ), text );
|
||||
|
||||
text = 'align, noshade, size, width on hr elements';
|
||||
testString = '<hr align="left" noshade="noshade" size="1" width="100" />';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { hr: 'align noshade size width' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { hr: 'align noshade size width' } ), text );
|
||||
|
||||
text = 'align, frameborder, marginheight, marginwidth, scrolling on iframe elements';
|
||||
testString = '<p><iframe width="100" height="100" frameborder="1" marginwidth="5" marginheight="5" scrolling="" align="left"></iframe></p>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { iframe: 'align frameborder marginheight marginwidth scrolling' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { iframe: 'align frameborder marginheight marginwidth scrolling' } ), text );
|
||||
|
||||
text = 'type on li elements';
|
||||
testString = '<ul><li type="disc">test</li></ul>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'align, border, hspace, vspace on object elements';
|
||||
testString = '<p><object width="100" height="100" border="1" vspace="5" hspace="5" align="left"></object></p>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { object: 'align border hspace vspace' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { object: 'align border hspace vspace' } ), text );
|
||||
|
||||
text = 'compact on ol elements';
|
||||
testString = '<ol compact="compact"><li>test</li></ol>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
|
||||
text = 'compact, type on ul elements';
|
||||
testString = '<ul type="disc" compact="compact"><li>test</li></ul>';
|
||||
editor.setContent( testString );
|
||||
ok( hasAttr( editor.getContent(), { ul: 'compact type' } ), text );
|
||||
assert.ok( hasAttr( editor.getContent(), { ul: 'compact type' } ), text );
|
||||
|
||||
text = 'width on pre elements';
|
||||
testString = '<pre width="100">1</pre>';
|
||||
editor.setContent( testString );
|
||||
equal( editor.getContent(), testString, text );
|
||||
assert.equal( editor.getContent(), testString, text );
|
||||
});
|
||||
|
||||
} )( window.jQuery, window.QUnit, window.tinymce );
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* global wp, JSON */
|
||||
( function( QUnit ) {
|
||||
module( 'wpapi' );
|
||||
QUnit.module( 'wpapi' );
|
||||
|
||||
QUnit.test( 'API Loaded correctly', function( assert ) {
|
||||
var done = assert.async();
|
||||
@ -122,7 +122,7 @@
|
||||
|
||||
_.each( modelsWithIdsClassNames, function( className ) {
|
||||
|
||||
QUnit.test( 'Checking ' + className + ' model.' , function( assert ) {
|
||||
QUnit.test( 'Checking ' + className + ' model.', function( assert ) {
|
||||
var done = assert.async();
|
||||
|
||||
assert.expect( 2 );
|
||||
@ -160,7 +160,7 @@
|
||||
|
||||
_.each( modelsWithIndexes, function( className ) {
|
||||
|
||||
QUnit.test( 'Testing ' + className + ' model.' , function( assert ) {
|
||||
QUnit.test( 'Testing ' + className + ' model.', function( assert ) {
|
||||
var done = assert.async();
|
||||
|
||||
assert.expect( 2 );
|
||||
@ -296,7 +296,7 @@
|
||||
|
||||
// Check that we have and can get each model type.
|
||||
_.each( customClasses, function( className ) {
|
||||
QUnit.test( 'Checking ' + className + ' class name.' , function( assert ) {
|
||||
QUnit.test( 'Checking ' + className + ' class name.', function( assert ) {
|
||||
var done = assert.async();
|
||||
|
||||
assert.expect( 2 );
|
||||
@ -316,7 +316,7 @@
|
||||
|
||||
// Check connecting to a second URL.
|
||||
wp.api.loadPromise.done( function() {
|
||||
QUnit.test( 'Checking connecting to a remote url.' , function( assert ) {
|
||||
QUnit.test( 'Checking connecting to a remote url.', function( assert ) {
|
||||
var done = assert.async();
|
||||
|
||||
wp.api.init({
|
||||
|
Loading…
Reference in New Issue
Block a user