Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { expect } from 'chai';
import { spy } from 'sinon';
import { describe, it } from 'mocha';
import ExportManager from '../../src/exporter/ExportManager';
describe('ExportManager', () => {
describe('static methods', () => {
describe('registerExporterClass', () => {
const subject = ExportManager.registerExporterClass.bind(ExportManager);
it('should set new entity to exporters property', () => {
expect((ExportManager as any).exporters.size).to.equal(0);
subject('test', {} as any, {} as any);
expect((ExportManager as any).exporters.size).to.equal(1);
});
});
});
describe('instance methods', () => {
const instance = new ExportManager();
describe('loadPlugins', () => {
const subject = instance.loadPlugins.bind(instance);
describe('when invalid path was given', () => {
it('should throw uncaught error', () => {
expect(() => subject('/dev/null')).to.throw(Error);
});
});
});
describe('exportScene', () => {
const subject = instance.exportScene.bind(instance);
const validRuntimeName = 'test_runtime';
const invalidRuntimeName = 'invalid_test_runtime';
const stubExporters = { scene: {} as any, asset: {} };
before(() => {
(ExportManager as any).exporters = new Map();
(ExportManager as any).exporters.set(validRuntimeName, stubExporters);
});
describe('when valid runtime identifier was given', () => {
before(() => { stubExporters.scene = spy(); });
it('should instantiate scene exporter class', () => {
try {
subject(validRuntimeName, [], '');
} catch(e) {}
expect(stubExporters.scene.calledWithNew()).to.be.true;
});
});
describe('when invalid runtime identifier was given', () => {
before(() => { stubExporters.scene = spy(); });
it('should throw managed error', () => {
expect(() => subject(invalidRuntimeName, [], '')).to.throw(Error);
expect(stubExporters.scene.calledWithNew()).to.be.false;
});
});
});
describe('exportAsset', () => {
const subject = instance.exportAsset.bind(instance);
const validRuntimeName = 'test_runtime';
const invalidRuntimeName = 'invalid_test_runtime';
const stubExporters = { scene: {}, asset: {} as any };
before(() => {
(ExportManager as any).exporters = new Map();
(ExportManager as any).exporters.set(validRuntimeName, stubExporters);
});
describe('when valid runtime identifier was given', () => {
before(() => { stubExporters.asset = spy(); });
it('should instantiate asset exporter class', () => {
try {
subject(new Map(), validRuntimeName, [], '');
} catch(e) {}
expect(stubExporters.asset.calledWithNew()).to.be.true;
});
});
describe('when invalid runtime identifier was given', () => {
before(() => { stubExporters.asset = spy(); });
it('should throw managed error', () => {
expect(() => subject(new Map(), invalidRuntimeName, [], '')).to.throw(Error);
expect(stubExporters.asset.calledWithNew()).to.be.false;
});
});
});
});
});
|