');
68 | jira.should.eql('[http://google.com]');
69 | });
70 | it('should convert named links properly', () => {
71 | const jira = j2m.to_jira('[Google](http://google.com)');
72 | jira.should.eql('[Google|http://google.com]');
73 | });
74 | it('should convert headers properly', () => {
75 | const h1 = j2m.to_jira('# Biggest heading');
76 | const h2 = j2m.to_jira('## Bigger heading');
77 | const h3 = j2m.to_jira('### Big heading');
78 | const h4 = j2m.to_jira('#### Normal heading');
79 | const h5 = j2m.to_jira('##### Small heading');
80 | const h6 = j2m.to_jira('###### Smallest heading');
81 | h1.should.eql('h1. Biggest heading');
82 | h2.should.eql('h2. Bigger heading');
83 | h3.should.eql('h3. Big heading');
84 | h4.should.eql('h4. Normal heading');
85 | h5.should.eql('h5. Small heading');
86 | h6.should.eql('h6. Smallest heading');
87 | });
88 | it('should convert underline-style headers properly', () => {
89 | const h1 = j2m.to_jira('Biggest heading\n=======');
90 | const h2 = j2m.to_jira('Bigger heading\n------');
91 | h1.should.eql('h1. Biggest heading');
92 | h2.should.eql('h2. Bigger heading');
93 | });
94 | it('should convert blockquotes properly', () => {
95 | const jira = j2m.to_jira('> This is a long blockquote type thingy that needs to be converted.');
96 | jira.should.eql('bq. This is a long blockquote type thingy that needs to be converted.');
97 | });
98 | it('should convert un-ordered lists properly', () => {
99 | const jira = j2m.to_jira('* Foo\n* Bar\n* Baz\n * FooBar\n * BarBaz\n * FooBarBaz\n* Starting Over');
100 | jira.should.eql('* Foo\n* Bar\n* Baz\n** FooBar\n** BarBaz\n*** FooBarBaz\n* Starting Over');
101 | });
102 | it('should convert ordered lists properly', () => {
103 | const jira = j2m.to_jira(
104 | '1. Foo\n1. Bar\n1. Baz\n 1. FooBar\n 1. BarBaz\n 1. FooBarBaz\n1. Starting Over'
105 | );
106 | jira.should.eql('# Foo\n# Bar\n# Baz\n## FooBar\n## BarBaz\n### FooBarBaz\n# Starting Over');
107 | });
108 | it('should handle bold AND italic (combined) correctly', () => {
109 | const jira = j2m.to_jira('This is ***emphatically bold***!');
110 | jira.should.eql('This is _*emphatically bold*_!');
111 | });
112 | it('should handle bold within a un-ordered list item', () => {
113 | const jira = j2m.to_jira('* This is not bold!\n * This is **bold**.');
114 | jira.should.eql('* This is not bold!\n** This is *bold*.');
115 | });
116 | it('should be able to handle a complicated multi-line markdown string and convert it to markdown', () => {
117 | const jiraStr = fs.readFileSync(path.resolve(__dirname, 'test.jira'), 'utf8');
118 | const mdStr = fs.readFileSync(path.resolve(__dirname, 'test.md'), 'utf8');
119 | const jira = j2m.to_jira(mdStr);
120 | jira.should.eql(jiraStr);
121 | });
122 | });
123 |
--------------------------------------------------------------------------------
/test/test.html:
--------------------------------------------------------------------------------
1 | Biggest heading
2 | Bigger heading
3 | Biggest heading
4 | Bigger heading
5 | Big heading
6 | Normal heading
7 | Small heading
8 | Smallest heading
9 | strong
emphasis
monospaced
deleted
inserted
superscript
subscript
10 | var hello = 'world';
11 |
12 | 

13 | http://google.com
Google
14 | GitHub Flavor
deleted
15 | preformatted piece of text
16 | so *no_ further _formatting* is done here
17 |
18 | Should be bold AND italic
19 |
20 | - First li
21 | - Second li
22 | - Indented li
23 | - Three columns in li
24 |
25 |
26 |
27 |
28 | - Back to first level li
29 |
30 |
31 | - First li
32 | - Second li
33 | - Indented li
34 | - Three columns in li
35 |
36 |
37 |
38 |
39 | - Back to first level li
40 |
41 |
42 | - Here's italic inside li
43 | - here's bold inside li
44 | - Here's bold + italic inside li
45 | - Here they are in one line indented: italic bold
46 |
47 |
48 |
49 |
50 | Here's a long single-paragraph block quote. It should look pretty and stuff.
51 |
52 |
53 |
54 |
55 | | A title |
56 |
57 |
58 |
59 | | Panel text |
60 |
61 |
62 |
63 |
64 |
65 | | Heading 1 |
66 | Heading 2 |
67 |
68 |
69 |
70 | | Col A1 |
71 | Col A2 |
72 |
73 |
74 | | Col B1 |
75 | Col B2 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/test/test.jira:
--------------------------------------------------------------------------------
1 | h1. Biggest heading
2 |
3 | h2. Bigger heading
4 |
5 | h1. Biggest heading
6 | h2. Bigger heading
7 | h3. Big heading
8 | h4. Normal heading
9 | h5. Small heading
10 | h6. Smallest heading
11 |
12 | *strong*
13 | _emphasis_
14 | {{monospaced}}
15 | -deleted-
16 | +inserted+
17 | ^superscript^
18 | ~subscript~
19 |
20 | {code:javascript}
21 | var hello = 'world';
22 | {code}
23 |
24 | !http://google.com/image!
25 | [!http://google.com/image!|http://google.com/link]
26 |
27 | [http://google.com]
28 | [Google|http://google.com]
29 |
30 | GitHub Flavor
31 | -deleted-
32 |
33 | {code}
34 | preformatted piece of text
35 | so _no_ further _formatting_ is done here
36 | {code}
37 |
38 | _*Should be bold AND italic*_
39 |
40 | * First li
41 | * Second li
42 | ** Indented li
43 | *** Three columns in li
44 | * Back to first level li
45 |
46 | # First li
47 | # Second li
48 | ## Indented li
49 | ### Three columns in li
50 | # Back to first level li
51 |
52 | * Here's _italic_ inside li
53 | * here's *bold* inside li
54 | * Here's _*bold + italic*_ inside li
55 | ** Here they are in one line indented: _italic_ *bold*
56 |
57 | bq. Here's a long single-paragraph block quote. It should look pretty and stuff.
58 |
59 | {panel:title=A title}
60 | Panel text
61 | {panel}
62 |
63 | ||Heading 1||Heading 2||
64 | |Col A1|Col A2|
65 | |Col B1|Col B2|
66 |
--------------------------------------------------------------------------------
/test/test.md:
--------------------------------------------------------------------------------
1 | # Biggest heading
2 |
3 | ## Bigger heading
4 |
5 | # Biggest heading
6 | ## Bigger heading
7 | ### Big heading
8 | #### Normal heading
9 | ##### Small heading
10 | ###### Smallest heading
11 |
12 | **strong**
13 | *emphasis*
14 | `monospaced`
15 | ~~deleted~~
16 | inserted
17 | superscript
18 | subscript
19 |
20 | ```javascript
21 | var hello = 'world';
22 | ```
23 |
24 | 
25 | [](http://google.com/link)
26 |
27 |
28 | [Google](http://google.com)
29 |
30 | GitHub Flavor
31 | ~~deleted~~
32 |
33 | ```
34 | preformatted piece of text
35 | so *no_ further _formatting* is done here
36 | ```
37 |
38 | ***Should be bold AND italic***
39 |
40 | * First li
41 | * Second li
42 | * Indented li
43 | * Three columns in li
44 | * Back to first level li
45 |
46 | 1. First li
47 | 1. Second li
48 | 1. Indented li
49 | 1. Three columns in li
50 | 1. Back to first level li
51 |
52 | * Here's *italic* inside li
53 | * here's **bold** inside li
54 | * Here's ***bold + italic*** inside li
55 | * Here they are in one line indented: *italic* **bold**
56 |
57 | > Here's a long single-paragraph block quote. It should look pretty and stuff.
58 |
59 |
60 | | A title |
61 | | --- |
62 | | Panel text |
63 |
64 |
65 | |Heading 1|Heading 2|
66 | | --- | --- |
67 | |Col A1|Col A2|
68 | |Col B1|Col B2|
69 |
--------------------------------------------------------------------------------
/test/to_html.js:
--------------------------------------------------------------------------------
1 | const should = require('chai').should();
2 | const fs = require('fs');
3 | const path = require('path');
4 |
5 | const j2m = require('../index');
6 |
7 | describe('md_to_html', () => {
8 | it('should exist', () => {
9 | should.exist(j2m.md_to_html(''));
10 | });
11 |
12 | it('should be a function', () => {
13 | j2m.md_to_html.should.be.a('function');
14 | });
15 |
16 | it('should provide html from md', () => {
17 | const mdStr = fs.readFileSync(path.resolve(__dirname, 'test.md'), 'utf8');
18 | const htmlStr = fs.readFileSync(path.resolve(__dirname, 'test.html'), 'utf8');
19 |
20 | const html = j2m.md_to_html(mdStr);
21 | html.should.eql(htmlStr);
22 | });
23 | });
24 |
25 | describe('jira_to_html', () => {
26 | it('should exist', () => {
27 | should.exist(j2m.jira_to_html(''));
28 | });
29 |
30 | it('should be a function', () => {
31 | j2m.jira_to_html.should.be.a('function');
32 | });
33 |
34 | it('should provide html from md', () => {
35 | const jiraStr = fs.readFileSync(path.resolve(__dirname, 'test.jira'), 'utf8');
36 | const htmlStr = fs.readFileSync(path.resolve(__dirname, 'test.html'), 'utf8');
37 |
38 | const html = j2m.jira_to_html(jiraStr);
39 | html.should.eql(htmlStr);
40 | });
41 | });
42 |
--------------------------------------------------------------------------------