mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-17 06:16:35 +03:00
43 lines
931 B
JavaScript
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();
|
|
});
|
|
})
|
|
})
|