1 | import React from 'react';
|
2 | import {shallow, mount} from 'enzyme';
|
3 |
|
4 | import Code from '../code/code';
|
5 | import Link from '../link/link';
|
6 |
|
7 | import Markdown from './markdown';
|
8 |
|
9 | describe('Markdown', () => {
|
10 | const shallowMarkdown = props => shallow(
|
11 | <Markdown
|
12 | source=""
|
13 | {...props}
|
14 | />
|
15 | );
|
16 | const mountMarkdown = props => mount(
|
17 | <Markdown
|
18 | source=""
|
19 | {...props}
|
20 | />
|
21 | );
|
22 |
|
23 | it('should wrap children with div', () => {
|
24 | shallowMarkdown().should.have.tagName('div');
|
25 | });
|
26 |
|
27 | it('should use passed className', () => {
|
28 | shallowMarkdown({className: 'test-class'}).should.have.className('test-class');
|
29 | });
|
30 |
|
31 | it('should convert links to ring Links', () => {
|
32 | const wrapper = mountMarkdown({source: '[link](/)'});
|
33 | wrapper.should.have.descendants(Link);
|
34 | });
|
35 |
|
36 | it('should convert inline code to ring Code', () => {
|
37 | const wrapper = mountMarkdown({source: '`some(code)`'});
|
38 | wrapper.should.have.descendants(Code);
|
39 | });
|
40 |
|
41 | it('should convert block code to ring Code', () => {
|
42 | const wrapper = mountMarkdown({
|
43 | source: `
|
44 | \`\`\`
|
45 | some(code)
|
46 | \`\`\`
|
47 | `
|
48 | });
|
49 | wrapper.should.have.descendants(Code);
|
50 | });
|
51 |
|
52 | it('should convert not finished code block to empty ring Code', () => {
|
53 | const wrapper = mountMarkdown({
|
54 | source: `
|
55 | \`\`\`
|
56 | `
|
57 | });
|
58 | wrapper.should.have.descendants(Code);
|
59 | });
|
60 | });
|