2016-08-04 17:49:32 +02:00
|
|
|
/* eslint-env qunit */
|
2015-10-28 19:28:15 +02:00
|
|
|
import CloseButton from '../../src/js/close-button';
|
2016-08-04 17:49:32 +02:00
|
|
|
import sinon from 'sinon';
|
2015-10-28 19:28:15 +02:00
|
|
|
import TestHelpers from './test-helpers';
|
|
|
|
|
2016-08-04 17:49:32 +02:00
|
|
|
QUnit.module('CloseButton', {
|
2015-10-28 19:28:15 +02:00
|
|
|
|
2016-08-04 17:49:32 +02:00
|
|
|
beforeEach() {
|
2015-10-28 19:28:15 +02:00
|
|
|
this.player = TestHelpers.makePlayer();
|
|
|
|
this.btn = new CloseButton(this.player);
|
|
|
|
},
|
|
|
|
|
2016-08-04 17:49:32 +02:00
|
|
|
afterEach() {
|
2015-10-28 19:28:15 +02:00
|
|
|
this.player.dispose();
|
|
|
|
this.btn.dispose();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-08-04 17:49:32 +02:00
|
|
|
QUnit.test('should create the expected element', function(assert) {
|
|
|
|
const elAssertions = TestHelpers.assertEl(assert, this.btn.el(), {
|
2015-10-28 19:28:15 +02:00
|
|
|
tagName: 'button',
|
|
|
|
classes: [
|
|
|
|
'vjs-button',
|
|
|
|
'vjs-close-button',
|
|
|
|
'vjs-control'
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.expect(elAssertions.count + 1);
|
|
|
|
elAssertions();
|
|
|
|
assert.strictEqual(this.btn.el().querySelector('.vjs-control-text').innerHTML, 'Close');
|
|
|
|
});
|
|
|
|
|
2016-08-04 17:49:32 +02:00
|
|
|
QUnit.test('should allow setting the controlText_ property as an option', function(assert) {
|
|
|
|
const text = 'OK!';
|
|
|
|
const btn = new CloseButton(this.player, {controlText: text});
|
2015-10-28 19:28:15 +02:00
|
|
|
|
|
|
|
assert.expect(1);
|
|
|
|
assert.strictEqual(btn.controlText_, text, 'set the controlText_ property');
|
2019-03-18 21:49:48 +02:00
|
|
|
|
|
|
|
btn.dispose();
|
2015-10-28 19:28:15 +02:00
|
|
|
});
|
|
|
|
|
2016-08-04 17:49:32 +02:00
|
|
|
QUnit.test('should trigger an event on activation', function(assert) {
|
|
|
|
const spy = sinon.spy();
|
2015-10-28 19:28:15 +02:00
|
|
|
|
|
|
|
this.btn.on('close', spy);
|
|
|
|
this.btn.trigger('click');
|
|
|
|
assert.expect(1);
|
|
|
|
assert.strictEqual(spy.callCount, 1, 'the "close" event was triggered');
|
|
|
|
});
|