@@ -3,7 +3,8 @@ const { load } = require('cheerio')
3
3
const { sortBy } = require ( 'lodash' )
4
4
const mjml = require ( '../lib' )
5
5
6
- const input = `
6
+ async function run ( ) {
7
+ const input = `
7
8
<mjml>
8
9
<mj-head>
9
10
<mj-html-attributes>
@@ -35,44 +36,49 @@ const input = `
35
36
</mjml>
36
37
`
37
38
38
- const { html } = mjml ( input )
39
- const $ = load ( html )
39
+ const { html } = await mjml ( input )
40
+ const $ = load ( html )
40
41
41
- // should put the attributes at the right place
42
- chai
43
- . expect (
44
- $ ( '.text div' )
45
- . map ( function getAttr ( ) {
46
- return $ ( this ) . attr ( 'data-id' )
47
- } )
48
- . get ( ) ,
49
- 'Custom attributes added on texts' ,
50
- )
51
- . to . eql ( [ '42' , '42' ] )
42
+ // should put the attributes at the right place
43
+ chai
44
+ . expect (
45
+ $ ( '.text div' )
46
+ . map ( function getAttr ( ) {
47
+ return $ ( this ) . attr ( 'data-id' )
48
+ } )
49
+ . get ( ) ,
50
+ 'Custom attributes added on texts' ,
51
+ )
52
+ . to . eql ( [ '42' , '42' ] )
52
53
53
- chai
54
- . expect (
55
- $ ( '.image td' )
56
- . map ( function getAttr ( ) {
57
- return $ ( this ) . attr ( 'data-name' )
58
- } )
59
- . get ( ) ,
60
- 'Custom attributes added on image' ,
61
- )
62
- . to . eql ( [ '43' ] )
54
+ chai
55
+ . expect (
56
+ $ ( '.image td' )
57
+ . map ( function getAttr ( ) {
58
+ return $ ( this ) . attr ( 'data-name' )
59
+ } )
60
+ . get ( ) ,
61
+ 'Custom attributes added on image' ,
62
+ )
63
+ . to . eql ( [ '43' ] )
63
64
64
- // should not alter templating syntax, or move the content that is outside any tag (mj-raws)
65
- const expected = [
66
- '{ if item < 5 }' ,
67
- 'class="section"' ,
68
- '{ if item > 10 }' ,
69
- 'class="text"' ,
70
- '{ item }' ,
71
- '{ end if }' ,
72
- '{ item + 1 }' ,
73
- ]
74
- const indexes = expected . map ( ( str ) => html . indexOf ( str ) )
65
+ // should not alter templating syntax, or move the content that is outside any tag (mj-raws)
66
+ const expected = [
67
+ '{ if item < 5 }' ,
68
+ 'class="section"' ,
69
+ '{ if item > 10 }' ,
70
+ 'class="text"' ,
71
+ '{ item }' ,
72
+ '{ end if }' ,
73
+ '{ item + 1 }' ,
74
+ ]
75
+ const indexes = expected . map ( ( str ) => html . indexOf ( str ) )
75
76
76
- chai . expect ( indexes , 'Templating syntax unaltered' ) . to . not . include ( - 1 )
77
+ chai . expect ( indexes , 'Templating syntax unaltered' ) . to . not . include ( - 1 )
77
78
78
- chai . expect ( sortBy ( indexes ) , 'Mj-raws kept same positions' ) . to . deep . eql ( indexes )
79
+ chai
80
+ . expect ( sortBy ( indexes ) , 'Mj-raws kept same positions' )
81
+ . to . deep . eql ( indexes )
82
+ }
83
+
84
+ run ( )
0 commit comments