Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosang committed Jun 7, 2018
1 parent 0a890ec commit 3ed1bc2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions test/unit/mocks/StreamControllerMock.js
Expand Up @@ -46,6 +46,8 @@ class StreamControllerMock {
setConfig() {}

reset() {}

getActiveStreamProcessors() { return [];}
}

export default StreamControllerMock;
13 changes: 7 additions & 6 deletions test/unit/streaming.text.NotFragmentedTextBufferController.js
Expand Up @@ -133,7 +133,7 @@ describe('NotFragmentedTextBufferController', function () {
});

describe('Method switchInitData', function () {
it('should append init data to source buffer if data have been cached', function () {
it('should not append init data to source buffer if data have already been cached', function () {
let chunk = {
bytes: 'initData',
quality: 2,
Expand All @@ -148,19 +148,19 @@ describe('NotFragmentedTextBufferController', function () {
notFragmentedTextBufferController.createBuffer(mockMediaInfo);
const buffer = notFragmentedTextBufferController.getBuffer().getBuffer();
notFragmentedTextBufferController.switchInitData(chunk.streamId, chunk.representationId);
expect(buffer.chunk).to.equal(chunk.bytes);
expect(buffer.chunk).to.equal(null);
});

it('should trigger INIT_REQUESTED if no init data is cached', function (done) {
it('should trigger TIMED_TEXT_REQUESTED if no init data is cached', function (done) {

// reset cache
initCache.reset();

let onInitRequest = function () {
eventBus.off(Events.INIT_REQUESTED, onInitRequest);
eventBus.off(Events.TIMED_TEXT_REQUESTED, onInitRequest);
done();
};
eventBus.on(Events.INIT_REQUESTED, onInitRequest, this);
eventBus.on(Events.TIMED_TEXT_REQUESTED, onInitRequest, this);

notFragmentedTextBufferController.switchInitData('streamId', 'representationId');
});
Expand All @@ -172,7 +172,8 @@ describe('NotFragmentedTextBufferController', function () {

let event = {
sender: {
getStreamProcessor: function () { return streamProcessorMock; }
getStreamProcessor: function () { return streamProcessorMock; },
getCurrentRepresentation: function () { return { id: 0}; }
}
};

Expand Down
5 changes: 4 additions & 1 deletion test/unit/streaming.text.TextController.js
Expand Up @@ -6,6 +6,7 @@ import EventBus from '../../src/core/EventBus';
import Events from '../../src/core/events/Events';

import VideoModelMock from './mocks/VideoModelMock';
import StreamControllerMock from './mocks/StreamControllerMock';

const expect = require('chai').expect;
const context = {};
Expand All @@ -16,6 +17,7 @@ const eventBus = EventBus(context).getInstance();
describe('TextController', function () {

let videoModelMock = new VideoModelMock();
let streamControllerMock = new StreamControllerMock();
let textTracks;
let textController;

Expand All @@ -27,7 +29,8 @@ describe('TextController', function () {

textController = TextController(context).getInstance();
textController.setConfig({
videoModel: videoModelMock
videoModel: videoModelMock,
streamController: streamControllerMock
});
});

Expand Down

0 comments on commit 3ed1bc2

Please sign in to comment.