Jeff Williams 865b9faa1e
feat(jsdoc-core): add Api class
Starting point for a public API for JSDoc.
2023-12-27 12:46:21 -08:00

54 lines
1.3 KiB
JavaScript

/*
Copyright 2023 the JSDoc Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import EventEmitter from 'node:events';
import Api from '../../../lib/api.js';
describe('Api', () => {
let instance;
beforeEach(() => {
instance = new Api();
});
it('is a constructor', () => {
function factory() {
return new Api();
}
expect(factory).not.toThrow();
});
it('has an `emitter` property', () => {
expect(instance.emitter).toBeObject();
});
describe('emitter', () => {
it('is an instance of `EventEmitter` by default', () => {
expect(instance.emitter).toBeInstanceOf(EventEmitter);
});
it('lets you provide your own emitter', () => {
const fakeEmitter = {};
instance = new Api({ emitter: fakeEmitter });
expect(instance.emitter).toBe(fakeEmitter);
});
});
});