diff --git a/src/js/menu/menu-button.js b/src/js/menu/menu-button.js index 274b48626..1b9a8d6ca 100644 --- a/src/js/menu/menu-button.js +++ b/src/js/menu/menu-button.js @@ -256,6 +256,7 @@ class MenuButton extends Component { */ handleMouseLeave(event) { this.removeClass('vjs-hover'); + this.buttonPressed_ = false; Events.off(document, 'keyup', this.handleMenuKeyUp_); } diff --git a/test/unit/menu.test.js b/test/unit/menu.test.js index cc2925ec8..8a2c3f6e6 100644 --- a/test/unit/menu.test.js +++ b/test/unit/menu.test.js @@ -100,6 +100,39 @@ QUnit.test('clicking should display the menu', function(assert) { 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) { const player = TestHelpers.makePlayer(); diff --git a/test/unit/menu/menu-button.test.js b/test/unit/menu/menu-button.test.js deleted file mode 100644 index 3b40fd9c2..000000000 --- a/test/unit/menu/menu-button.test.js +++ /dev/null @@ -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(); - } -});