redoc/tests/unit/schema-manager.spec.js
2015-12-09 23:46:27 +02:00

43 lines
931 B
JavaScript

import SchemaManager from 'lib/utils/SchemaManager';
describe("Schema manager", () => {
let schemaMgr;
beforeEach(() => {
schemaMgr = new SchemaManager();
});
it("Should initialize with empty schema", ()=> {
schemaMgr.schema.should.be.empty;
});
it("Should be a singleton", ()=> {
(new SchemaManager()).should.be.equal(schemaMgr);
});
describe("load method", ()=> {
let req = null;
let xhr = null;
before(function () {
// fake XHR
xhr = sinon.useFakeXMLHttpRequest();
});
it("should return a promise", ()=> {
schemaMgr.load('http://test').should.be.instanceof(Promise);
});
it("should reject promise for non-existing schema", (done)=> {
schemaMgr.load('http://test').then(() => {
throw new Error("Should not be called")
}, (err) => {
done();
});
});
after(function () {
xhr.restore();
});
})
})