Skip to content

Commit

Permalink
Fix offEvent function with callback
Browse files Browse the repository at this point in the history
  • Loading branch information
artemAdp committed Sep 11, 2024
1 parent 431b85e commit 08eb3b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/adplayerproVideoProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ export function AdPlayerProProvider(config, adPlayerPro_, callbackStorage_, util
const playerEventName = utils.getPlayerEvent(event);
const eventHandler = callbackStorage.getCallback(playerEventName, callback);
if (eventHandler) {
player && player.off(playerEventName);
} else {
player && player.off(playerEventName, eventHandler);
} else {
player && player.off(playerEventName);
}
callbackStorage.clearCallback(playerEventName, callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ describe('AdPlayerProProvider', function () {
provider.offEvent(AD_IMPRESSION, callback);
expect(offSpy.calledOnce).to.be.true;
const eventName = offSpy.args[0][0];
const eventCallback = offSpy.args[0][1];
expect(eventName).to.be.equal('AdImpression');
expect(eventCallback).to.be.exist;
});

it('should remove event listener on player by eventName', function () {
Expand Down

0 comments on commit 08eb3b2

Please sign in to comment.