adds tests for editor-api.start()

This commit is contained in:
aaronmyatt 2020-12-16 21:53:52 +08:00
parent c9bc530df0
commit 55e6c6e01a
1 changed files with 23 additions and 0 deletions

View File

@ -156,4 +156,27 @@ describe("api/index", function() {
})
});
describe('editor start', function (done) {
it('cannot be started when editor is disabled', function (done) {
const stub = sinon.stub(apiEditor, 'start', function () {
return Promise.resolve(true);
});
api.init({ httpAdminRoot: true, disableEditor: true }, {}, {}, {});
should(api.start()).resolvedWith(true);
stub.restore();
done();
});
it('can be started when editor enabled', function (done) {
const stub = sinon.stub(apiEditor, 'start');
api.init({ httpAdminRoot: true, disableEditor: false }, {}, {}, {});
api.start();
should(stub.called).be.true();
stub.restore();
done();
});
});
});