1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-21 01:39:04 +02:00

add tests for mouseenter and mouseleave functionality

This commit is contained in:
usmanonazim 2023-03-21 14:29:01 +00:00
parent 2dcada103c
commit 4c13134d1b
3 changed files with 34 additions and 13 deletions

View File

@ -256,6 +256,7 @@ class MenuButton extends Component {
*/ */
handleMouseLeave(event) { handleMouseLeave(event) {
this.removeClass('vjs-hover'); this.removeClass('vjs-hover');
this.buttonPressed_ = false;
Events.off(document, 'keyup', this.handleMenuKeyUp_); Events.off(document, 'keyup', this.handleMenuKeyUp_);
} }

View File

@ -100,6 +100,39 @@ QUnit.test('clicking should display the menu', function(assert) {
player.dispose(); player.dispose();
}); });
QUnit.test('hovering should display the menu', function(assert) {
assert.expect(5);
const player = TestHelpers.makePlayer();
// Make sure there's some content in the menu, even if it's just a title!
const menuButton = new MenuButton(player, {
title: 'testTitle'
});
const el = menuButton.el();
assert.ok(menuButton.menu !== undefined, 'menu is created');
Events.trigger(el, 'mouseenter');
assert.ok(menuButton.hasClass('vjs-hover'), 'menu button is in hover state');
Events.trigger(el, 'mouseleave');
assert.ok(!menuButton.hasClass('vjs-hover'), 'menu button is no longer in hover state');
Events.trigger(el, 'mouseenter');
assert.ok(menuButton.hasClass('vjs-hover'), 'menu button is in hover state');
Events.trigger(menuButton.menuButton_.el(), 'click');
assert.ok(menuButton.menu.hasClass('vjs-hidden'), 'menu is hidden when clicked after mouseenter');
menuButton.dispose();
player.dispose();
});
QUnit.test('should keep all the added menu items', function(assert) { QUnit.test('should keep all the added menu items', function(assert) {
const player = TestHelpers.makePlayer(); const player = TestHelpers.makePlayer();

View File

@ -1,13 +0,0 @@
/* eslint-env qunit */
import TestHelpers from '../test-helpers.js';
QUnit.module('MenuButton', {
beforeEach(assert) {
this.player = TestHelpers.makePlayer({
});
},
afterEach(assert) {
this.player.dispose();
}
});