forked from angular/angular.io
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconvertBackticksToCodeBlocks.spec.js
58 lines (51 loc) · 1.4 KB
/
convertBackticksToCodeBlocks.spec.js
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
var mockPackage = require('../mocks/mockPackage');
var Dgeni = require('dgeni');
var path = require('canonical-path');
describe('convertBackticksToCodeBlocks', function() {
var dgeni, injector, processor;
beforeEach(function() {
dgeni = new Dgeni([mockPackage()]);
injector = dgeni.configureInjector();
processor = injector.get('convertBackticksToCodeBlocks');
});
it('should convert backtick code blocks to code-example blocks', function() {
var docs = [{
renderedContent:
'preamble\n' +
'```ts\n' +
'export class TypeScriptClass {\n' +
'}\n' +
'```\n' +
'postamble\n'
}];
processor.$process(docs);
expect(docs[0].renderedContent).toEqual(
'preamble\n' +
'\n' +
'code-example(format="linenums" language="ts").\n' +
'export class TypeScriptClass {\n' +
'}\n' +
'\n' +
':marked\n' +
'postamble\n'
);
});
it('should ignore docs that have been marked as having unbalanced backticks', function() {
var docs = [{
renderedContent:
'preamble\n' +
'```ts\n' +
'export class TypeScriptClass {\n' +
'}\n' +
'postamble\n'
}];
processor.$process(docs);
expect(docs[0].renderedContent).toEqual(
'preamble\n' +
'```ts\n' +
'export class TypeScriptClass {\n' +
'}\n' +
'postamble\n'
);
})
});