2015-09-16 02:21:55 -04:00
|
|
|
var mockPackage = require('../mocks/mockPackage');
|
|
|
|
var Dgeni = require('dgeni');
|
|
|
|
|
|
|
|
describe('addJadeDataDocsProcessor', function() {
|
|
|
|
var dgeni, injector, processor;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
dgeni = new Dgeni([mockPackage()]);
|
|
|
|
injector = dgeni.configureInjector();
|
|
|
|
processor = injector.get('addJadeDataDocsProcessor');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should add a doc for each module', function() {
|
2015-11-04 06:10:24 -05:00
|
|
|
var exportDoc;
|
2015-09-16 02:21:55 -04:00
|
|
|
var docs = [
|
|
|
|
{
|
|
|
|
docType: 'module',
|
|
|
|
id: 'someModule',
|
2015-09-18 07:12:32 -04:00
|
|
|
exports: [
|
2015-11-04 06:10:24 -05:00
|
|
|
exportDoc = { name: 'someObj', docType: 'var', symbolTypeName: 'MyClass', originalModule: 'some/private/module' }
|
2015-09-18 07:12:32 -04:00
|
|
|
],
|
2015-09-16 02:21:55 -04:00
|
|
|
fileInfo: { baseName: 'x_y' },
|
|
|
|
description: 'some description\nsecond line'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
docs = processor.$process(docs);
|
|
|
|
|
2015-11-04 06:10:24 -05:00
|
|
|
expect(docs.filter(function(doc) { return doc.docType === 'jade-data'; })[0]).toEqual({
|
2015-09-16 02:21:55 -04:00
|
|
|
id : 'someModule-data',
|
|
|
|
aliases : [ 'someModule-data' ],
|
|
|
|
docType : 'jade-data',
|
|
|
|
originalDoc : docs[0],
|
|
|
|
data : [
|
2015-09-18 06:59:37 -04:00
|
|
|
{ name : 'index', title : 'X Y', intro : 'some description second line', docType : 'module' },
|
2015-11-04 06:10:24 -05:00
|
|
|
{ name : 'someObj-var', title : 'someObj', varType : 'MyClass', docType: 'var',
|
|
|
|
originalModule: 'some/private/module', exportDoc: exportDoc }
|
2015-09-16 02:21:55 -04:00
|
|
|
] });
|
|
|
|
});
|
2015-09-18 06:54:29 -04:00
|
|
|
|
|
|
|
it('should sort the exports into alphabetical order', function() {
|
2015-11-04 06:10:24 -05:00
|
|
|
var alpha, beta, gamma, nu, mu;
|
2015-09-18 06:54:29 -04:00
|
|
|
var docs = [
|
|
|
|
{
|
|
|
|
docType: 'module',
|
|
|
|
id: 'someModule',
|
|
|
|
exports: [
|
2015-11-04 06:10:24 -05:00
|
|
|
beta = { name: 'Beta', docType: 'class'},
|
|
|
|
alpha = { name: 'Alpha', docType: 'class'},
|
|
|
|
gamma = { name: 'Gamma', docType: 'class'},
|
|
|
|
nu = { name: 'Nu', docType: 'class'},
|
|
|
|
mu = { name: 'Mu', docType: 'class'}
|
2015-09-18 06:54:29 -04:00
|
|
|
],
|
|
|
|
fileInfo: { baseName: 'x_y' },
|
|
|
|
description: 'some description\nsecond line'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
docs = processor.$process(docs);
|
|
|
|
|
2015-11-04 06:10:24 -05:00
|
|
|
expect(docs[2].data).toEqual([
|
2015-09-18 06:59:37 -04:00
|
|
|
{ name : 'index', title : 'X Y', intro : 'some description second line', docType : 'module' },
|
2015-11-04 06:10:24 -05:00
|
|
|
{ name: 'Alpha-class', title: 'Alpha', docType: 'class', exportDoc: alpha },
|
|
|
|
{ name: 'Beta-class', title: 'Beta', docType: 'class', exportDoc: beta },
|
|
|
|
{ name: 'Gamma-class', title: 'Gamma', docType: 'class', exportDoc: gamma },
|
|
|
|
{ name: 'Mu-class', title: 'Mu', docType: 'class', exportDoc: mu },
|
|
|
|
{ name: 'Nu-class', title: 'Nu', docType: 'class', exportDoc: nu }
|
2015-09-18 06:54:29 -04:00
|
|
|
]);
|
|
|
|
|
2015-09-18 06:59:37 -04:00
|
|
|
});
|
|
|
|
});
|