Skip to content

Commit 207e619

Browse files
committed
add non empty array test for getSynthesizedLocationElements
1 parent b25a62a commit 207e619

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

test/unit/test/dash/dash.controllers.ContentSteeringController.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,72 @@ describe('ContentSteeringController', function () {
278278

279279
expect(result).to.be.an('array').that.is.empty;
280280
});
281+
282+
it('should return synthesized location elements when steering response data is present', async function () {
283+
const referenceElements = [
284+
{
285+
url: 'https://example.com/manifest.mpd',
286+
serviceLocation: 'cdn1'
287+
}
288+
];
289+
290+
const mockLoaderInstance = {
291+
load: ({ success, complete }) => {
292+
const responseData = {};
293+
responseData[DashConstants.CONTENT_STEERING_RESPONSE.VERSION] = '1';
294+
responseData[DashConstants.CONTENT_STEERING_RESPONSE.PATHWAY_CLONES] = [
295+
{
296+
[DashConstants.CONTENT_STEERING_RESPONSE.BASE_ID]: 'cdn1',
297+
[DashConstants.CONTENT_STEERING_RESPONSE.ID]: 'clone1',
298+
[DashConstants.CONTENT_STEERING_RESPONSE.URI_REPLACEMENT]: {
299+
[DashConstants.CONTENT_STEERING_RESPONSE.HOST]: 'clone.example.com',
300+
[DashConstants.CONTENT_STEERING_RESPONSE.PARAMS]: { foo: 'bar' }
301+
}
302+
}
303+
];
304+
305+
success(responseData);
306+
if (typeof complete === 'function') {
307+
complete();
308+
}
309+
},
310+
abort: () => {},
311+
reset: () => {},
312+
resetInitialSettings: () => {}
313+
};
314+
315+
function MockLoader() {
316+
return {
317+
create: () => mockLoaderInstance
318+
};
319+
}
320+
321+
const schemeLoaderFactory = SchemeLoaderFactory(context).getInstance();
322+
323+
schemeLoaderFactory.registerLoader('https://', MockLoader);
324+
325+
manifestModelMock.getValue = sinon.stub().returns({});
326+
adapterMock.getContentSteering = sinon.stub().returns({
327+
serverUrl: 'https://steering.example.com',
328+
queryBeforeStart: true
329+
});
330+
331+
contentSteeringController.initialize();
332+
333+
try {
334+
await contentSteeringController.loadSteeringData();
335+
const result = contentSteeringController.getSynthesizedLocationElements(referenceElements);
336+
337+
expect(result).to.be.an('array').that.is.not.empty;
338+
const synthesized = result[0];
339+
340+
expect(synthesized.url).to.equal('https://clone.example.com/manifest.mpd');
341+
expect(synthesized.serviceLocation).to.equal('clone1');
342+
expect(synthesized.queryParams).to.deep.equal({ foo: 'bar' });
343+
} finally {
344+
schemeLoaderFactory.unregisterLoader('https://');
345+
}
346+
});
281347
});
282348

283349
describe('Event handling', function () {

0 commit comments

Comments
 (0)