This repository was archived by the owner on Feb 5, 2025. It is now read-only.
forked from pattern-lab/patternlab-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkdown_parser_tests.js
More file actions
50 lines (38 loc) · 1.74 KB
/
markdown_parser_tests.js
File metadata and controls
50 lines (38 loc) · 1.74 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
"use strict";
var tap = require('tap');
var path = require('path');
var fs = require('fs-extra');
var mp = require('../core/lib/markdown_parser');
var markdown_parser = new mp();
tap.test('parses pattern description block correctly when frontmatter not present', function(test) {
//arrange
var markdownFileName = path.resolve("./test/files/_patterns/00-test/00-foo.md");
var markdownFileContents = fs.readFileSync(markdownFileName, 'utf8');
//act
var returnObject = markdown_parser.parse(markdownFileContents);
//assert
test.equals(returnObject.markdown, '<h2>A Simple Include</h2>\n<p>This pattern contains an include of <code>test-bar</code>. It also has this markdown file, which does not have frontmatter.</p>\n');
test.end();
});
tap.test('parses pattern description block correctly when frontmatter present', function (test) {
//arrange
var markdownFileName = path.resolve("./test/files/_patterns/00-test/01-bar.md");
var markdownFileContents = fs.readFileSync(markdownFileName, 'utf8');
//act
var returnObject = markdown_parser.parse(markdownFileContents);
//assert
test.equals(returnObject.markdown, '<h2>A Simple Bit of Markup</h2>\n<p>Foo cannot get simpler than bar, amiright?</p>\n');
test.equals(returnObject.status, 'complete');
test.end();
});
tap.test('parses frontmatter only when no markdown present', function (test) {
//arrange
var markdownFileName = path.resolve("./test/files/_patterns/00-test/03-styled-atom.md");
var markdownFileContents = fs.readFileSync(markdownFileName, 'utf8');
//act
var returnObject = markdown_parser.parse(markdownFileContents);
//assert
test.equals(returnObject.markdown, '');
test.equals(returnObject.status, 'inprogress');
test.end();
});