Skip to content

Commit

Permalink
test: add even more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Nfrederiksen committed Nov 27, 2024
1 parent ab23aeb commit d2b11a6
Showing 1 changed file with 95 additions and 5 deletions.
100 changes: 95 additions & 5 deletions spec/hls_splice_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,46 @@ describe("HLSSpliceVod", () => {
});
});

it("can insert interstitial with an asset uri and a resume offset and invalid CUE attribute", (done) => {
const mockVod = new HLSSpliceVod("http://mock.com/mock.m3u8");
mockVod
.load(mockMasterManifest, mockMediaManifest)
.then(() => {
return mockVod.insertInterstitialAt(18000, "001", "http://mock.com/asseturi", false, {
resumeOffset: 10500,
cue: "pre-once",
});
})
.then(() => {
const m3u8 = mockVod.getMediaManifest(4497000);
const lines = m3u8.split("\n");
expect(lines[12]).toEqual(
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",X-RESUME-OFFSET=10.5'
);
done();
});
});

it("can insert interstitial with an asset uri and a resume offset and single CUE attribute", (done) => {
const mockVod = new HLSSpliceVod("http://mock.com/mock.m3u8");
mockVod
.load(mockMasterManifest, mockMediaManifest)
.then(() => {
return mockVod.insertInterstitialAt(18000, "001", "http://mock.com/asseturi", false, {
resumeOffset: 10500,
cue: "POST",
});
})
.then(() => {
const m3u8 = mockVod.getMediaManifest(4497000);
const lines = m3u8.split("\n");
expect(lines[29]).toEqual(
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",CUE="POST",X-RESUME-OFFSET=10.5'
);
done();
});
});

it("can insert interstitial with an asset uri and a resume offset that is 0", (done) => {
const mockVod = new HLSSpliceVod("http://mock.com/mock.m3u8");
mockVod
Expand Down Expand Up @@ -1490,19 +1530,69 @@ describe("HLSSpliceVod with Demuxed Audio Tracks,", () => {
.then(() => {
return mockVod.insertInterstitialAt(18000, "001", "http://mock.com/asseturi", false, {
resumeOffset: 10500,
cue: "POST,ONCE"
cue: "PRE,ONCE",
});
})
.then(() => {
const m3u8 = mockVod.getMediaManifest(4497000);
let lines = m3u8.split("\n");
expect(lines[29]).toEqual(
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",CUE="POST,ONCE",X-RESUME-OFFSET=10.5'
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",CUE="PRE,ONCE",X-RESUME-OFFSET=10.5'
);
const m3u8Audio = mockVod.getAudioManifest("stereo", "sv");
lines = m3u8Audio.split("\n");
expect(lines[29]).toEqual(
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",CUE="POST,ONCE",X-RESUME-OFFSET=10.5'
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",CUE="PRE,ONCE",X-RESUME-OFFSET=10.5'
);
done();
});
});

it("can insert interstitial with an asset uri and a resume offset and invalid CUE attribute", (done) => {
const mockVod = new HLSSpliceVod("http://mock.com/mock.m3u8");
mockVod
.load(mockMasterManifest, mockMediaManifest, mockAudioManifest)
.then(() => {
return mockVod.insertInterstitialAt(18000, "001", "http://mock.com/asseturi", false, {
resumeOffset: 10500,
cue: "ROST,TWICE",
});
})
.then(() => {
const m3u8 = mockVod.getMediaManifest(4497000);
let lines = m3u8.split("\n");
expect(lines[12]).toEqual(
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",X-RESUME-OFFSET=10.5'
);
const m3u8Audio = mockVod.getAudioManifest("stereo", "sv");
lines = m3u8Audio.split("\n");
expect(lines[12]).toEqual(
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",X-RESUME-OFFSET=10.5'
);
done();
});
});

it("can insert interstitial with an asset uri and a resume offset and partially valid CUE attribute", (done) => {
const mockVod = new HLSSpliceVod("http://mock.com/mock.m3u8");
mockVod
.load(mockMasterManifest, mockMediaManifest, mockAudioManifest)
.then(() => {
return mockVod.insertInterstitialAt(18000, "001", "http://mock.com/asseturi", false, {
resumeOffset: 10500,
cue: "POST,THRICE",
});
})
.then(() => {
const m3u8 = mockVod.getMediaManifest(4497000);
let lines = m3u8.split("\n");
expect(lines[29]).toEqual(
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",CUE="POST",X-RESUME-OFFSET=10.5'
);
const m3u8Audio = mockVod.getAudioManifest("stereo", "sv");
lines = m3u8Audio.split("\n");
expect(lines[29]).toEqual(
'#EXT-X-DATERANGE:ID="001",CLASS="com.apple.hls.interstitial",START-DATE="1970-01-01T00:00:18.001Z",X-ASSET-URI="http://mock.com/asseturi",CUE="POST",X-RESUME-OFFSET=10.5'
);
done();
});
Expand All @@ -1514,7 +1604,7 @@ describe("HLSSpliceVod with Demuxed Audio Tracks,", () => {
.load(mockMasterManifest, mockMediaManifest, mockAudioManifest)
.then(() => {
return mockVod.insertInterstitialAt(18000, "001", "http://mock.com/asseturi", false, {
resumeOffset: 0
resumeOffset: 0,
});
})
.then(() => {
Expand Down Expand Up @@ -2077,7 +2167,7 @@ test-audio=256000-6.m4s`;
.then(() => {
return mockVod.insertInterstitialAt(18000, "001", "http://mock.com/asseturi", false, {
resumeOffset: 10500,
cue: "POST,ONCE"
cue: "POST,ONCE",
});
})
.then(() => {
Expand Down

0 comments on commit d2b11a6

Please sign in to comment.