promise.js 731 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals describe, it, expect, CKEDITOR, window */
  6. 'use strict';
  7. describe( 'Promise', function() {
  8. it( 'should resolve properly', function( done ) {
  9. CKEDITOR.require( [ 'promise' ], function( Promise ) {
  10. var promise = new Promise( function( resolve ) {
  11. // Fake an asynchronous operation.
  12. window.setTimeout( function() {
  13. resolve( 1 );
  14. }, 0 );
  15. } );
  16. promise.then( function( value ) {
  17. // then() catches errors, so we need to delay the execution.
  18. window.setTimeout( function() {
  19. expect( value ).to.equal( 1 );
  20. done();
  21. } );
  22. } );
  23. } );
  24. } );
  25. } );