Repository navigation
Expand file tree
/
Copy pathsplitDescription.spec.js
More file actions
71 lines (65 loc) · 2.96 KB
/
Copy pathsplitDescription.spec.js
File metadata and controls
71 lines (65 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const testPackage = require('../../helpers/test-package');
const processorFactory = require('./splitDescription');
const Dgeni = require('dgeni');
describe('splitDescription processor', () => {
it('should be available on the injector', () => {
const dgeni = new Dgeni([testPackage('angular-api-package')]);
const injector = dgeni.configureInjector();
const processor = injector.get('splitDescription');
expect(processor.$process).toBeDefined();
});
it('should run before the correct processor', () => {
const processor = processorFactory();
expect(processor.$runBefore).toEqual(['processing-docs']);
});
it('should run after the correct processor', () => {
const processor = processorFactory();
expect(processor.$runAfter).toEqual(['tags-extracted', 'migrateLegacyJSDocTags']);
});
it('should split the `description` property into the first paragraph and other paragraphs', () => {
const processor = processorFactory();
processor.docTypes = ['test'];
const docs = [
{ docType: 'test' },
{ docType: 'test', description: '' },
{ docType: 'test', description: 'abc' },
{ docType: 'test', description: 'abc\n' },
{ docType: 'test', description: 'abc\n\n' },
{ docType: 'test', description: 'abc\ncde' },
{ docType: 'test', description: 'abc\ncde\n' },
{ docType: 'test', description: 'abc\n\ncde' },
{ docType: 'test', description: 'abc\n \ncde' },
{ docType: 'test', description: 'abc\n\n\ncde' },
{ docType: 'test', description: 'abc\n\ncde\nfgh' },
{ docType: 'test', description: 'abc\n\ncde\n\nfgh' },
];
processor.$process(docs);
expect(docs).toEqual([
{ docType: 'test' },
{ docType: 'test', shortDescription: '', description: '' },
{ docType: 'test', shortDescription: 'abc', description: '' },
{ docType: 'test', shortDescription: 'abc', description: '' },
{ docType: 'test', shortDescription: 'abc', description: '' },
{ docType: 'test', shortDescription: 'abc\ncde', description: '' },
{ docType: 'test', shortDescription: 'abc\ncde', description: '' },
{ docType: 'test', shortDescription: 'abc', description: 'cde' },
{ docType: 'test', shortDescription: 'abc', description: 'cde' },
{ docType: 'test', shortDescription: 'abc', description: 'cde' },
{ docType: 'test', shortDescription: 'abc', description: 'cde\nfgh' },
{ docType: 'test', shortDescription: 'abc', description: 'cde\n\nfgh' },
]);
});
it('should ignore docs that do not match the specified doc types', () => {
const processor = processorFactory();
processor.docTypes = ['test'];
const docs = [
{ docType: 'test', description: 'abc\n\ncde' },
{ docType: 'other', description: 'abc\n\ncde' }
];
processor.$process(docs);
expect(docs).toEqual([
{ docType: 'test', shortDescription: 'abc', description: 'cde' },
{ docType: 'other', description: 'abc\n\ncde' }
]);
});
});