Skip to content

Commit 5896f7f

Browse files
PascalThuetclaude
andcommitted
fix(tests): correct unit tests that pass without verifying behavior
- DashParser: replace .bind() with arrow functions so parse() is actually called with the intended arguments (lines 17-28) - DashParser: move async fixture loading from describe() scope into a before() hook — Mocha does not support async describe (line 64) - MssParser: same .bind() fix (line 62) - Stream: await the Promise from setMediaSource() so the assertion runs before Mocha marks the test as passed (lines 93-98) Fixes Dash-Industry-Forum#5011 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d4afee5 commit 5896f7f

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

test/unit/test/dash/dash.DashParser.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ const dashManifestModel = DashManifestModel(context).getInstance();
1515
describe('DashParser', function () {
1616

1717
it('should throw an error when parse is called without data and config object has been set properly', () => {
18-
expect(dashParser.parse.bind('')).to.be.throw('failed to parse the manifest');
18+
expect(() => dashParser.parse('')).to.throw('failed to parse the manifest');
1919
});
2020

2121
it('should throw an error when parse is called with invalid data', async () => {
2222
let manifest = await FileLoader.loadTextFile('/data/dash/manifest_error.xml');
23-
expect(dashParser.parse.bind(manifest)).to.be.throw('failed to parse the manifest');
23+
expect(() => dashParser.parse(manifest)).to.throw('failed to parse the manifest');
2424
});
2525

2626
it('should return an Object when parse is called with correct data', async () => {
2727
let manifest = await FileLoader.loadTextFile('/data/dash/manifest.xml');
28-
expect(dashParser.parse.bind(manifest)).to.be.instanceOf(Object);
28+
expect(dashParser.parse(manifest)).to.be.instanceOf(Object);
2929
});
3030

3131
describe('DashParser matchers', function () {
@@ -61,15 +61,19 @@ describe('DashParser', function () {
6161
});
6262
});
6363

64-
describe('DashParser - ObjectIron', async () => {
64+
describe('DashParser - ObjectIron', () => {
65+
let manifest_prop;
66+
67+
before(async () => {
68+
manifest_prop = await FileLoader.loadTextFile('/data/dash/manifest_properties.xml');
69+
});
70+
6571
beforeEach(function () {
6672
dashManifestModel.setConfig({
6773
errHandler: errorHandlerMock
6874
});
6975
});
7076

71-
let manifest_prop = await FileLoader.loadTextFile('/data/dash/manifest_properties.xml');
72-
7377
it('should map AudioChannelConfig even if another instance is present on Representation', async () => {
7478
let parsedMpd = dashParser.parse(manifest_prop);
7579
let audioAdaptationsArray = dashManifestModel.getAdaptationsForType(parsedMpd, 0, 'audio');

test/unit/test/mss/mss.parser.MssParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('MssParser', function () {
5959
});
6060

6161
it('should throw an error when parse is called with invalid smooth data', function () {
62-
expect(mssParser.parse.bind('<SmoothStreamingMedia')).to.be.throw('parsing the manifest failed');
62+
expect(() => mssParser.parse('<SmoothStreamingMedia')).to.throw('parsing the manifest failed');
6363
});
6464

6565
it('should map mss subtype to dash role', async () => {

test/unit/test/streaming/streaming.Stream.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,9 @@ describe('Stream', function () {
9090
expect(processors).to.be.empty; // jshint ignore:line
9191
});
9292

93-
it('should trigger MANIFEST_ERROR_ID_NOSTREAMS_CODE error when setMediaSource is called but streamProcessors array is empty', () => {
94-
stream.setMediaSource()
95-
.then(() => {
96-
expect(errHandlerMock.errorCode).to.be.equal(Errors.MANIFEST_ERROR_ID_NOSTREAMS_CODE); // jshint ignore:line
97-
})
93+
it('should trigger MANIFEST_ERROR_ID_NOSTREAMS_CODE error when setMediaSource is called but streamProcessors array is empty', async () => {
94+
await stream.setMediaSource();
95+
expect(errHandlerMock.errorCode).to.be.equal(Errors.MANIFEST_ERROR_ID_NOSTREAMS_CODE); // jshint ignore:line
9896
});
9997

10098
it('should return an null when getId is called but streamInfo attribute is null or undefined', () => {

0 commit comments

Comments
 (0)