@@ -35,6 +35,45 @@ describe('Markdoc - Content Collections', () => {
35
35
expect ( posts ) . to . not . be . null ;
36
36
expect ( posts . sort ( ) ) . to . deep . equal ( [ simplePostEntry , withComponentsEntry , withConfigEntry ] ) ;
37
37
} ) ;
38
+
39
+ it ( 'renders content - simple' , async ( ) => {
40
+ const res = await fixture . fetch ( '/content-simple' ) ;
41
+ const html = await res . text ( ) ;
42
+ const { document } = parseHTML ( html ) ;
43
+ const h2 = document . querySelector ( 'h2' ) ;
44
+ expect ( h2 . textContent ) . to . equal ( 'Simple post' ) ;
45
+ const p = document . querySelector ( 'p' ) ;
46
+ expect ( p . textContent ) . to . equal ( 'This is a simple Markdoc post.' ) ;
47
+ } ) ;
48
+
49
+ it ( 'renders content - with config' , async ( ) => {
50
+ const res = await fixture . fetch ( '/content-with-config' ) ;
51
+ const html = await res . text ( ) ;
52
+ const { document } = parseHTML ( html ) ;
53
+ const h2 = document . querySelector ( 'h2' ) ;
54
+ expect ( h2 . textContent ) . to . equal ( 'Post with config' ) ;
55
+ const marquee = document . querySelector ( 'marquee' ) ;
56
+ expect ( marquee ) . to . not . be . null ;
57
+ expect ( marquee . textContent ) . to . equal ( 'Im a marquee!' ) ;
58
+ } ) ;
59
+
60
+ it ( 'renders content - with components' , async ( ) => {
61
+ const res = await fixture . fetch ( '/content-with-components' ) ;
62
+ const html = await res . text ( ) ;
63
+ const { document } = parseHTML ( html ) ;
64
+ const h2 = document . querySelector ( 'h2' ) ;
65
+ expect ( h2 . textContent ) . to . equal ( 'Post with components' ) ;
66
+
67
+ // Renders custom shortcode component
68
+ const marquee = document . querySelector ( 'marquee' ) ;
69
+ expect ( marquee ) . to . not . be . null ;
70
+ expect ( marquee . hasAttribute ( 'data-custom-marquee' ) ) . to . equal ( true ) ;
71
+
72
+ // Renders Astro Code component
73
+ const pre = document . querySelector ( 'pre' ) ;
74
+ expect ( pre ) . to . not . be . null ;
75
+ expect ( pre . className ) . to . equal ( 'astro-code' ) ;
76
+ } ) ;
38
77
} ) ;
39
78
40
79
describe ( 'build' , ( ) => {
@@ -54,6 +93,42 @@ describe('Markdoc - Content Collections', () => {
54
93
expect ( posts ) . to . not . be . null ;
55
94
expect ( posts . sort ( ) ) . to . deep . equal ( [ simplePostEntry , withComponentsEntry , withConfigEntry ] ) ;
56
95
} ) ;
96
+
97
+ it ( 'renders content - simple' , async ( ) => {
98
+ const html = await fixture . readFile ( '/content-simple/index.html' ) ;
99
+ const { document } = parseHTML ( html ) ;
100
+ const h2 = document . querySelector ( 'h2' ) ;
101
+ expect ( h2 . textContent ) . to . equal ( 'Simple post' ) ;
102
+ const p = document . querySelector ( 'p' ) ;
103
+ expect ( p . textContent ) . to . equal ( 'This is a simple Markdoc post.' ) ;
104
+ } ) ;
105
+
106
+ it ( 'renders content - with config' , async ( ) => {
107
+ const html = await fixture . readFile ( '/content-with-config/index.html' ) ;
108
+ const { document } = parseHTML ( html ) ;
109
+ const h2 = document . querySelector ( 'h2' ) ;
110
+ expect ( h2 . textContent ) . to . equal ( 'Post with config' ) ;
111
+ const marquee = document . querySelector ( 'marquee' ) ;
112
+ expect ( marquee ) . to . not . be . null ;
113
+ expect ( marquee . textContent ) . to . equal ( 'Im a marquee!' ) ;
114
+ } ) ;
115
+
116
+ it ( 'renders content - with components' , async ( ) => {
117
+ const html = await fixture . readFile ( '/content-with-components/index.html' ) ;
118
+ const { document } = parseHTML ( html ) ;
119
+ const h2 = document . querySelector ( 'h2' ) ;
120
+ expect ( h2 . textContent ) . to . equal ( 'Post with components' ) ;
121
+
122
+ // Renders custom shortcode component
123
+ const marquee = document . querySelector ( 'marquee' ) ;
124
+ expect ( marquee ) . to . not . be . null ;
125
+ expect ( marquee . hasAttribute ( 'data-custom-marquee' ) ) . to . equal ( true ) ;
126
+
127
+ // Renders Astro Code component
128
+ const pre = document . querySelector ( 'pre' ) ;
129
+ expect ( pre ) . to . not . be . null ;
130
+ expect ( pre . className ) . to . equal ( 'astro-code' ) ;
131
+ } ) ;
57
132
} ) ;
58
133
} ) ;
59
134
0 commit comments