test-media-gallery-widget.js 1.5 KB

123456789101112131415161718192021222324252627282930
  1. /* global wp */
  2. /* jshint qunit: true */
  3. /* eslint-env qunit */
  4. /* eslint-disable no-magic-numbers */
  5. ( function() {
  6. 'use strict';
  7. QUnit.module( 'Gallery Media Widget' );
  8. QUnit.test( 'gallery widget control', function( assert ) {
  9. var GalleryWidgetControl;
  10. assert.equal( typeof wp.mediaWidgets.controlConstructors.media_gallery, 'function', 'wp.mediaWidgets.controlConstructors.media_gallery is a function' );
  11. GalleryWidgetControl = wp.mediaWidgets.controlConstructors.media_gallery;
  12. assert.ok( GalleryWidgetControl.prototype instanceof wp.mediaWidgets.MediaWidgetControl, 'wp.mediaWidgets.controlConstructors.media_gallery subclasses wp.mediaWidgets.MediaWidgetControl' );
  13. });
  14. QUnit.test( 'gallery media model', function( assert ) {
  15. var GalleryWidgetModel, galleryWidgetModelInstance;
  16. assert.equal( typeof wp.mediaWidgets.modelConstructors.media_gallery, 'function', 'wp.mediaWidgets.modelConstructors.media_gallery is a function' );
  17. GalleryWidgetModel = wp.mediaWidgets.modelConstructors.media_gallery;
  18. assert.ok( GalleryWidgetModel.prototype instanceof wp.mediaWidgets.MediaWidgetModel, 'wp.mediaWidgets.modelConstructors.media_gallery subclasses wp.mediaWidgets.MediaWidgetModel' );
  19. galleryWidgetModelInstance = new GalleryWidgetModel();
  20. _.each( galleryWidgetModelInstance.attributes, function( value, key ) {
  21. assert.equal( value, GalleryWidgetModel.prototype.schema[ key ][ 'default' ], 'Should properly set default for ' + key );
  22. });
  23. });
  24. })();