From 26fcc0cffbd651f43b0bdb4e256bcb1d20e39ec6 Mon Sep 17 00:00:00 2001 From: Borut Zizmond Date: Fri, 21 Feb 2025 14:11:03 +0100 Subject: [PATCH] test: Add unit tests for pendingSeekTime when SmartTV focus moves away without confirmation --- test/unit/controls.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/unit/controls.test.js b/test/unit/controls.test.js index 94127a0913..e11d5409de 100644 --- a/test/unit/controls.test.js +++ b/test/unit/controls.test.js @@ -688,6 +688,7 @@ QUnit.module('SmartTV UI Updates (Progress Bar & Time Display)', function(hooks) hooks.beforeEach(function() { player = TestHelpers.makePlayer({ + spatialNavigation: { enabled: true }, disableSeekWhileScrubbingOnSTV: true, controlBar: { progressControl: { @@ -778,4 +779,15 @@ QUnit.module('SmartTV UI Updates (Progress Bar & Time Display)', function(hooks) 'Current-time-display should remain at 45s after seeking' ); }); + + QUnit.test('Resets pendingSeekTime when SmartTV focus moves away without confirmation', function(assert) { + const userSeekSpy = sinon.spy(seekBar, 'userSeek_'); + + seekBar.trigger({ type: 'keydown', key: 'ArrowUp' }); + assert.ok(seekBar.pendingSeekTime() !== null, 'pendingSeekTime should be set after ArrowUp keydown'); + seekBar.trigger({ type: 'keydown', key: 'ArrowLeft' }); + assert.equal(seekBar.pendingSeekTime(), null, 'pendingSeekTime should be reset when SeekBar loses focus'); + assert.ok(userSeekSpy.calledWith(player.currentTime()), 'userSeek_ should be called with current player time'); + userSeekSpy.restore(); + }); });