mirror of
https://github.com/videojs/video.js.git
synced 2024-12-10 11:10:19 +02:00
26b0d2cadd
The core goal here is to make sure the following works in light of some middleware process that makes setting the source more async than next tick: ```js player.src('...'); player.ready(() => player.play()); ``` In fact, given this change, we should even be able to do: ```js player.src('...'); player.play(); ``` Unlike #4665, which would have clarified/changed the meaning of "ready", it remains a reflection of the tech's state and we make better use of the ability to queue things on that state and on the middleware `setSource` process.
21 lines
728 B
JavaScript
21 lines
728 B
JavaScript
/* eslint-env qunit */
|
|
import window from 'global/window';
|
|
import * as promise from '../../../src/js/utils/promise';
|
|
|
|
QUnit.module('utils/promise');
|
|
|
|
QUnit.test('can correctly identify a native Promise (if supported)', function(assert) {
|
|
|
|
// If Promises aren't supported, skip this.
|
|
if (!window.Promise) {
|
|
return assert.expect(0);
|
|
}
|
|
|
|
assert.ok(promise.isPromise(new window.Promise((resolve) => resolve())), 'a native Promise was recognized');
|
|
});
|
|
|
|
QUnit.test('can identify a Promise-like object', function(assert) {
|
|
assert.notOk(promise.isPromise({}), 'an object without a `then` method is not Promise-like');
|
|
assert.ok(promise.isPromise({then: () => {}}), 'an object with a `then` method is Promise-like');
|
|
});
|