Skip to content

Commit

Permalink
Merge pull request #2027 from Orange-OpenSource/add_config_test_Segme…
Browse files Browse the repository at this point in the history
…ntBaseLoader

SegmentBaseLoader tests
  • Loading branch information
Dan Sparacio authored Jun 21, 2017
2 parents c65cfa4 + 585910e commit d5bbbc7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/dash/SegmentBaseLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ function SegmentBaseLoader() {
}
}

function checkSetConfigCall() {
if (!baseURLController || !baseURLController.hasOwnProperty('resolve')) {
throw new Error('setConfig function has to be called previously');
}
}

function loadInitialization(representation, loadingInfo) {
checkSetConfigCall();
let initRange = null;
let isoFile = null;
let baseUrl = baseURLController.resolve(representation.path);
Expand Down Expand Up @@ -132,6 +139,7 @@ function SegmentBaseLoader() {
}

function loadSegments(representation, type, range, loadingInfo, callback) {
checkSetConfigCall();
if (range && (range.start === undefined || range.end === undefined)) {
let parts = range ? range.toString().split('-') : null;
range = parts ? {start: parseFloat(parts[0]), end: parseFloat(parts[1])} : null;
Expand Down
16 changes: 16 additions & 0 deletions test/unit/dash.SegmentBaseLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import SegmentBaseLoader from '../../src/dash/SegmentBaseLoader';

const expect = require('chai').expect;

const context = {};
const segmentBaseLoader = SegmentBaseLoader(context).getInstance();

describe('SegmentBaseLoader', function () {
it("should throw an exception when attempting to call loadInitialization While the setConfig function was not called, and parameters are undefined", function () {
expect(segmentBaseLoader.loadInitialization.bind(segmentBaseLoader)).to.throw('setConfig function has to be called previously');
});

it("should throw an exception when attempting to call loadSegments While the setConfig function was not called, and parameters are undefined", function () {
expect(segmentBaseLoader.loadSegments.bind(segmentBaseLoader)).to.throw('setConfig function has to be called previously');
});
});

0 comments on commit d5bbbc7

Please sign in to comment.