Skip to content
Permalink
Browse files

Update views manager test and cleanup leaky api tests

  • Loading branch information...
robwalch committed May 10, 2019
1 parent 5e83c39 commit ccbde58dacfa0f4da54881ced95034fc72c2668b
Showing with 21 additions and 13 deletions.
  1. +12 −3 test/unit/setup-test.js
  2. +9 −10 test/unit/view-manager-test.js
@@ -15,6 +15,8 @@ describe('api.setup', function() {

const errorMessage = 'This video file cannot be played.';

let api = null;

beforeEach(function () {
ApiSettings.debug = true;
// add fixture
@@ -31,18 +33,25 @@ describe('api.setup', function() {
ApiSettings.debug = false;
// remove fixture and player instances
const fixture = document.querySelector('#test-fixture');
if (api) {
api.remove();
}
if (fixture.parentNode) {
fixture.parentNode.removeChild(fixture);
}
for (let i = instances.length; i--;) {
instances[i].remove();
}
sandbox.restore();
api = null;
});

function expectReady(model) {
if (api) {
api.remove();
}
const container = document.querySelector('#player');
const api = new Api(container);
api = new Api(container);

return new Promise((resolve, reject) => {
api.setup(model);
@@ -61,7 +70,7 @@ describe('api.setup', function() {

function expectSetupError(model) {
const container = document.querySelector('#player');
const api = new Api(container);
api = new Api(container);

return new Promise((resolve, reject) => {
api.setup(model);
@@ -178,7 +187,7 @@ describe('api.setup', function() {
const removeSpy2 = sinon.spy();

const container = document.querySelector('#player');
const api = new Api(container);
api = new Api(container);

return new Promise((resolve, reject) => {
api.setup({
@@ -1,18 +1,17 @@
import sinon from 'sinon';
import ViewsManager from 'view/utils/views-manager';

describe('ViewsManager', function() {
describe('#add', () => {
it('sets the responsive sizing function of the passed in view', () => {
let funcMock = sinon.spy();
let view = {
setResponsiveResizeCallback: funcMock
};

describe('#size', () => {
it('returns the number of views added', () => {
const view = {};
expect(ViewsManager.size()).to.equal(0);
ViewsManager.add(view);
ViewsManager.add(view);
expect(funcMock.called).to.be.true;
expect(typeof funcMock.getCall(0).args[0]).to.eq('function');
expect(ViewsManager.size()).to.equal(2);
ViewsManager.remove(view);
expect(ViewsManager.size()).to.equal(1);
ViewsManager.remove(view);
expect(ViewsManager.size()).to.equal(0);
});
});
});

0 comments on commit ccbde58

Please sign in to comment.
You can’t perform that action at this time.