2017-03-12 09:27:47 -04:00
|
|
|
const testPackage = require('../../helpers/test-package');
|
|
|
|
const mockLogger = require('dgeni/lib/mocks/log')(false);
|
|
|
|
const processorFactory = require('./generateKeywords');
|
|
|
|
const Dgeni = require('dgeni');
|
|
|
|
|
|
|
|
const mockReadFilesProcessor = {
|
|
|
|
basePath: 'base/path'
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('generateKeywords processor', () => {
|
|
|
|
|
|
|
|
it('should be available on the injector', () => {
|
2017-04-21 08:10:52 -04:00
|
|
|
const dgeni = new Dgeni([testPackage('angular-base-package')]);
|
2017-03-12 09:27:47 -04:00
|
|
|
const injector = dgeni.configureInjector();
|
|
|
|
const processor = injector.get('generateKeywordsProcessor');
|
|
|
|
expect(processor.$process).toBeDefined();
|
|
|
|
});
|
|
|
|
|
2017-03-21 06:57:58 -04:00
|
|
|
it('should run after the correct processor', () => {
|
2017-03-12 09:27:47 -04:00
|
|
|
const processor = processorFactory(mockLogger, mockReadFilesProcessor);
|
|
|
|
expect(processor.$runAfter).toEqual(['paths-computed']);
|
|
|
|
});
|
|
|
|
|
2017-03-21 06:57:58 -04:00
|
|
|
it('should run before the correct processor', () => {
|
2017-03-12 09:27:47 -04:00
|
|
|
const processor = processorFactory(mockLogger, mockReadFilesProcessor);
|
|
|
|
expect(processor.$runBefore).toEqual(['rendering-docs']);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should ignore internal and private exports', () => {
|
|
|
|
const processor = processorFactory(mockLogger, mockReadFilesProcessor);
|
|
|
|
const docs = [
|
|
|
|
{ docType: 'class', name: 'PublicExport' },
|
|
|
|
{ docType: 'class', name: 'PrivateExport', privateExport: true },
|
|
|
|
{ docType: 'class', name: 'InternalExport', internal: true }
|
|
|
|
];
|
|
|
|
processor.$process(docs);
|
|
|
|
expect(docs[docs.length - 1].data).toEqual([
|
|
|
|
jasmine.objectContaining({ title: 'PublicExport', type: 'class'})
|
|
|
|
]);
|
|
|
|
});
|
2017-05-03 16:44:30 -04:00
|
|
|
|
|
|
|
it('should use `doc.searchTitle` as the title if available', () => {
|
|
|
|
const processor = processorFactory(mockLogger, mockReadFilesProcessor);
|
|
|
|
const docs = [
|
|
|
|
{ docType: 'class', name: 'PublicExport', searchTitle: 'class PublicExport' },
|
|
|
|
];
|
|
|
|
processor.$process(docs);
|
|
|
|
expect(docs[docs.length - 1].data).toEqual([
|
|
|
|
jasmine.objectContaining({ title: 'class PublicExport', type: 'class'})
|
|
|
|
]);
|
|
|
|
});
|
2017-03-12 09:27:47 -04:00
|
|
|
});
|