@@ -10,7 +10,7 @@ describe('Parse Markdown', () => {
10
10
let mdExample = '' ;
11
11
const mdFile = path . join ( __dirname , './examples/hello-world.md' ) ;
12
12
13
- before ( done => {
13
+ beforeAll ( done => {
14
14
fs . readFile ( mdFile , 'utf8' , ( err , data ) => {
15
15
if ( err ) {
16
16
return done ( err ) ;
@@ -23,24 +23,23 @@ describe('Parse Markdown', () => {
23
23
24
24
it ( 'extracts front matter from markdown' , ( ) => {
25
25
const result = parser . parseFrontMatter ( mdExample ) ;
26
- result . should . have . property ( 'attributes' ) ;
27
- result . should . have . property ( 'body' ) ;
26
+ expect ( result ) . toHaveProperty ( 'attributes' ) ;
27
+ expect ( result ) . toHaveProperty ( 'body' ) ;
28
28
} ) ;
29
29
30
30
it ( 'front matter attributes should contain imports object' , ( ) => {
31
31
const result = parser . parseFrontMatter ( mdExample ) ;
32
- result . attributes . should . have . property ( 'imports' ) ;
33
- result . attributes . imports . should . be . a ( 'object' ) ;
34
- result . attributes . imports . should
35
- . deep . equal ( { Button : './button.js' , HelloWorld : './hello-world.js' } ) ;
32
+ expect ( result . attributes ) . toHaveProperty ( 'imports' ) ;
33
+ expect ( result . attributes . imports ) . toBeInstanceOf ( Object ) ;
34
+ expect ( result . attributes . imports ) . toEqual ( { Button : './button.js' , HelloWorld : './hello-world.js' } ) ;
36
35
} ) ;
37
36
38
37
it ( 'example code blocks have run and source code' , ( ) => {
39
38
const
40
39
exampleCode = 'example' ,
41
40
result = parser . codeBlockTemplate ( exampleCode , exampleCode ) ;
42
41
43
- result . should . equal ( `
42
+ expect ( result ) . toEqual ( `
44
43
<div class="example">
45
44
<div class="run">example</div>
46
45
<div class="source">
@@ -51,32 +50,22 @@ describe('Parse Markdown', () => {
51
50
</div>` ) ;
52
51
} ) ;
53
52
54
- it ( 'parses markdown with live code blocks' , done => {
53
+ it ( 'parses markdown with live code blocks' , ( ) =>
55
54
parser . parse ( mdExample ) . then ( result => {
56
- result . html . should . contain ( `<div class="run"><HelloWorld />
57
- <Button label="Hello World" />
58
- </div>` ) ;
55
+ expect ( result . html ) . toMatch ( / < d i v c l a s s = " r u n " > < H e l l o W o r l d \/ > \s * < B u t t o n l a b e l = " H e l l o W o r l d " \/ > \s * < \/ d i v > / ) ;
59
56
} )
60
- . then ( done )
61
- . catch ( done ) ;
62
- } ) ;
57
+ ) ;
63
58
64
- it ( 'parses markdown and created valid html for JSX' , done => {
65
- const
66
- exampleCode = '' ;
67
- parser . parse ( exampleCode ) . then ( result => {
68
- result . html . should . equal ( '<p><img src="myImage.png" alt="" /></p>\n' ) ;
59
+ it ( 'parses markdown and created valid html for JSX' , ( ) =>
60
+ parser . parse ( '' ) . then ( result => {
61
+ expect ( result . html ) . toMatch ( / < p > < i m g s r c = " m y I m a g e .p n g " a l t = " " \/ > < \/ p > \n / ) ;
69
62
} )
70
- . then ( done )
71
- . catch ( done ) ;
72
- } ) ;
63
+ ) ;
73
64
74
- it ( 'provides the front-matter attributes' , done => {
65
+ it ( 'provides the front-matter attributes' , ( ) =>
75
66
parser . parse ( mdExample ) . then ( result => {
76
- result . attributes [ 'test-front-matter' ] . should . equal ( 'hello world' ) ;
67
+ expect ( result . attributes ) . toHaveProperty ( 'test-front-matter' , 'hello world' ) ;
77
68
} )
78
- . then ( done )
79
- . catch ( done ) ;
80
- } ) ;
69
+ ) ;
81
70
82
71
} ) ;
0 commit comments