2017-09-25 08:27:32 +02:00
|
|
|
/* global wp */
|
|
|
|
/* jshint qunit: true */
|
|
|
|
/* eslint-env qunit */
|
|
|
|
/* eslint-disable no-magic-numbers */
|
|
|
|
|
|
|
|
( function() {
|
|
|
|
'use strict';
|
|
|
|
|
2020-03-27 01:16:58 +01:00
|
|
|
QUnit.module( 'Gallery Media Widget' );
|
2017-09-25 08:27:32 +02:00
|
|
|
|
2020-03-27 01:16:58 +01:00
|
|
|
QUnit.test( 'gallery widget control', function( assert ) {
|
2017-09-25 08:27:32 +02:00
|
|
|
var GalleryWidgetControl;
|
2020-03-27 01:16:58 +01:00
|
|
|
assert.equal( typeof wp.mediaWidgets.controlConstructors.media_gallery, 'function', 'wp.mediaWidgets.controlConstructors.media_gallery is a function' );
|
2017-09-25 08:27:32 +02:00
|
|
|
GalleryWidgetControl = wp.mediaWidgets.controlConstructors.media_gallery;
|
2020-03-27 01:16:58 +01:00
|
|
|
assert.ok( GalleryWidgetControl.prototype instanceof wp.mediaWidgets.MediaWidgetControl, 'wp.mediaWidgets.controlConstructors.media_gallery subclasses wp.mediaWidgets.MediaWidgetControl' );
|
2017-09-25 08:27:32 +02:00
|
|
|
});
|
|
|
|
|
2020-03-27 01:16:58 +01:00
|
|
|
QUnit.test( 'gallery media model', function( assert ) {
|
2017-09-25 08:27:32 +02:00
|
|
|
var GalleryWidgetModel, galleryWidgetModelInstance;
|
2020-03-27 01:16:58 +01:00
|
|
|
assert.equal( typeof wp.mediaWidgets.modelConstructors.media_gallery, 'function', 'wp.mediaWidgets.modelConstructors.media_gallery is a function' );
|
2017-09-25 08:27:32 +02:00
|
|
|
GalleryWidgetModel = wp.mediaWidgets.modelConstructors.media_gallery;
|
2020-03-27 01:16:58 +01:00
|
|
|
assert.ok( GalleryWidgetModel.prototype instanceof wp.mediaWidgets.MediaWidgetModel, 'wp.mediaWidgets.modelConstructors.media_gallery subclasses wp.mediaWidgets.MediaWidgetModel' );
|
2017-09-25 08:27:32 +02:00
|
|
|
|
|
|
|
galleryWidgetModelInstance = new GalleryWidgetModel();
|
|
|
|
_.each( galleryWidgetModelInstance.attributes, function( value, key ) {
|
2020-03-27 01:16:58 +01:00
|
|
|
assert.equal( value, GalleryWidgetModel.prototype.schema[ key ][ 'default' ], 'Should properly set default for ' + key );
|
2017-09-25 08:27:32 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
})();
|