Skip to content

Commit

Permalink
add test for setCachedUrls with empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
SivanA-Kaltura committed Jun 6, 2024
1 parent 31a8ad8 commit 5f5cdfd
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions tests/src/dash-adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {wwDrmData, prDrmData} from './drm/fake-drm-data';
import shaka from 'shaka-player';
import {ImageTrack, ThumbnailInfo} from '@playkit-js/playkit-js';
import { expect } from 'chai';
import sinonChai from 'sinon-chai';

const targetId = 'player-placeholder_dash-adapter.spec';

Expand Down Expand Up @@ -2025,25 +2026,36 @@ describe('DashAdapter: setCachedUrls', () => {
remove = sandbox.stub(dashInstance.assetCache, "remove");
});

it("should not add the same url twice on consecutive calls", () => {
it("should not add the same url twice on a consecutive call", () => {
dashInstance.setCachedUrls(["abc"]);
dashInstance.setCachedUrls(["abc"]);
add.should.have.been.calledOnceWith("abc");
});

it("should add new urls on consecutive calls", () => {
it("should add new urls on a consecutive call", () => {
dashInstance.setCachedUrls(["abc"]);
add.should.have.been.calledWith("abc");
dashInstance.setCachedUrls(["abc", "def"]);
add.should.have.been.calledWith("def");
});

it("should remove asset urls that were initially added and are missing on consecutive calls", () => {
it("should remove asset urls that were initially added and are missing on a consecutive call", () => {
dashInstance.setCachedUrls(["abc"]);
add.should.have.been.calledWith("abc");
dashInstance.setCachedUrls(["def"]);
remove.should.have.been.calledWith("abc");
});

it("should remove all asset urls when receiving an empty array on a consecutive call", () => {
dashInstance.assetCache.list().length.should.equal(0);
dashInstance.setCachedUrls(["abc"]);
add.should.have.been.calledWith("abc");
dashInstance.setCachedUrls(["def"]);
add.should.have.been.calledWith("def");
dashInstance.setCachedUrls([]);
remove.should.have.been.calledWith("abc");
remove.should.have.been.calledWith("def");
});
});
});

Expand Down

0 comments on commit 5f5cdfd

Please sign in to comment.