jsdoc/test/specs/documentation/moduleisconstructor.js
Jeff Williams 617b3236bf Replace old, vendored Jasmine with current npm package.
JSDoc-specific test functions are now properties of a `jsdoc` global, not a `jasmine` global.

Also updates license files to reflect the fact that we no longer vendor anything.
2019-05-12 15:10:38 -07:00

90 lines
3.8 KiB
JavaScript

describe('module that exports a constructor', () => {
describe('pre-ES2015 module', () => {
const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduleisconstructor.js');
const modules = docSet.doclets.filter(({kind}) => kind === 'module');
const classes = docSet.doclets.filter(({kind}) => kind === 'class');
const getId = docSet.getByLongname('module:mymodule/config#getId')[0];
const id = docSet.getByLongname('module:mymodule/config#id')[0];
it('should include one doclet whose kind is "module"', () => {
expect(modules.length).toBe(1);
expect(modules[0].kind).toBe('module');
});
it('should include one doclet whose kind is "class"', () => {
expect(classes.length).toBe(1);
expect(classes[0].kind).toBe('class');
});
describe('class doclet', () => {
it('should include a "description" property that contains the constructor description', () => {
expect(classes[0].description).toEqual('Create a new configuration.');
});
it('should include a "classdesc" property', () => {
expect(classes[0].classdesc).toEqual('Describe the class here.');
});
});
describe('module doclet', () => {
it('should include a "description" property that contains the module description', () => {
expect(modules[0].description).toEqual('Describe the module here.');
});
});
describe('instance members', () => {
it('should use the correct longname for instance properties', () => {
expect(id.description).toBe('Document me.');
});
it('should use the correct longname for instance methods', () => {
expect(getId.description).toBe('Get the configuration ID.');
});
});
});
describe('ES2015 module', () => {
const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduleisconstructor2.js');
const modules = docSet.doclets.filter(({kind}) => kind === 'module');
const classes = docSet.doclets.filter(({kind, classdesc, description}) => kind === 'class' && classdesc && description);
const getId = docSet.getByLongname('module:mymodule/config#getId')[0];
const id = docSet.getByLongname('module:mymodule/config#id')[0];
it('should include one doclet whose kind is "module"', () => {
expect(modules.length).toBe(1);
expect(modules[0].kind).toBe('module');
});
it('should include one complete class doclet', () => {
expect(classes.length).toBe(1);
expect(classes[0].kind).toBe('class');
});
describe('class doclet', () => {
it('should include a "description" property that contains the constructor description', () => {
expect(classes[0].description).toEqual('Create a new configuration.');
});
it('should include a "classdesc" property', () => {
expect(classes[0].classdesc).toEqual('Describe the class here.');
});
});
describe('module doclet', () => {
it('should include a "description" property that contains the module description', () => {
expect(modules[0].description).toEqual('Describe the module here.');
});
});
describe('instance members', () => {
it('should use the correct longname for instance properties', () => {
expect(id.description).toBe('Document me.');
});
it('should use the correct longname for instance methods', () => {
expect(getId.description).toBe('Get the configuration ID.');
});
});
});
});