Wordpress/tests/qunit/wp-admin/js/customize-nav-menus.js
Aaron Jorbin b5f505d3dd Add Initial JS Unit Tests for Menu Customizer
While these two tests will help ensure we don't repeat our mistakes, they mostly help lay the foundation for more tests that still need to be written.

See #32688
Props adamsilverstein, jorbin



git-svn-id: https://develop.svn.wordpress.org/trunk@33451 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-27 22:07:27 +00:00

44 lines
1.1 KiB
JavaScript
Executable File

/* global wp */
jQuery( function( ) {
var api = wp.customize,
settings = window._wpCustomizeNavMenusSettings,
navMenu = window.wpNavMenu;
module( 'Customize Nav Menus', {
setup: function() {
window._wpCustomizeNavMenusSettings = settings;
window.wpNavMenu = navMenu;
},
teardown: function() {
// restore defaults
window._wpCustomizeNavMenusSettings = settings;
window.wpNavMenu = navMenu;
}
});
/**
* Generate 20 ids and verify they are all unique.
*/
test( 'generatePlaceholderAutoIncrementId generates unique IDs', function() {
var testIterations = 20,
ids = [ api.Menus.generatePlaceholderAutoIncrementId() ];
while( testIterations-- > 0 ) {
var placeholderID = api.Menus.generatePlaceholderAutoIncrementId();
ok( -1 === ids.indexOf( placeholderID ) );
ids.push( placeholderID );
}
} );
test( 'it should parse _wpCustomizeMenusSettings.defaults into itself', function() {
deepEqual( window._wpCustomizeNavMenusSettings, api.Menus.data );
});
});