@@ -16,15 +16,15 @@ describe("pat-markdown", function () {
16
16
afterEach ( ( ) => {
17
17
jest . restoreAllMocks ( ) ;
18
18
} ) ;
19
- it ( "It renders content for elements with the pattern trigger ." , async function ( ) {
19
+ it ( "Replaces the DOM element with the rendered Markdown content ." , async function ( ) {
20
20
var $el = $ ( '<p class="pat-markdown"></p>' ) ;
21
21
$el . appendTo ( "#lab" ) ;
22
22
jest . spyOn ( pattern . prototype , "render" ) . mockImplementation ( ( ) => {
23
23
return $ ( "<p>Rendering</p>" ) ;
24
24
} ) ;
25
25
pattern . init ( $el ) ;
26
26
await utils . timeout ( 1 ) ; // wait a tick for async to settle.
27
- expect ( $ ( "#lab" ) . html ( ) ) . toBe ( '<p class="pat-markdown" >Rendering</p>' ) ;
27
+ expect ( $ ( "#lab" ) . html ( ) ) . toBe ( "<p >Rendering</p>" ) ;
28
28
} ) ;
29
29
30
30
it ( "It does not render when the DOM element doesn't have the pattern trigger" , function ( ) {
@@ -162,26 +162,30 @@ describe("pat-markdown", function () {
162
162
163
163
describe ( "Code blocks" , function ( ) {
164
164
it ( "It correctly renders code blocks" , async function ( ) {
165
- document . body . innerHTML = `<div class="pat-markdown">
165
+ document . body . innerHTML = `
166
+ <main>
167
+ <div class="pat-markdown">
166
168
# Title
167
169
168
170
some content
169
171
170
172
\`\`\`javascript
171
173
const foo = "bar";
172
174
\`\`\`
173
- </div>
174
- ` ;
175
+
176
+ </div>
177
+ </main>
178
+ ` ;
175
179
176
180
new pattern ( document . querySelector ( ".pat-markdown" ) ) ;
177
181
await utils . timeout ( 1 ) ; // wait a tick for async to settle.
178
182
await utils . timeout ( 1 ) ; // wait a tick for async to settle.
179
183
180
- expect ( document . body . querySelector ( ".pat-markdown > h1" ) . textContent ) . toBe ( "Title" ) ; // prettier-ignore
181
- expect ( document . body . querySelector ( ".pat-markdown > p" ) . textContent ) . toBe ( "some content" ) ; // prettier-ignore
182
- expect ( document . body . querySelector ( ".pat-markdown > pre code" ) ) . toBeTruthy ( ) ; // prettier-ignore
183
- expect ( document . body . querySelector ( ".pat-markdown > pre.language-javascript code.language-javascript" ) ) . toBeTruthy ( ) ; // prettier-ignore
184
- expect ( document . body . querySelector ( ".pat-markdown > pre code .hljs-keyword" ) ) . toBeTruthy ( ) ; // prettier-ignore
184
+ expect ( document . body . querySelector ( "main > div > h1" ) . textContent ) . toBe ( "Title" ) ; // prettier-ignore
185
+ expect ( document . body . querySelector ( "main > div > p" ) . textContent ) . toBe ( "some content" ) ; // prettier-ignore
186
+ expect ( document . body . querySelector ( "main > div > pre code" ) ) . toBeTruthy ( ) ; // prettier-ignore
187
+ expect ( document . body . querySelector ( "main > div > pre.language-javascript code.language-javascript" ) ) . toBeTruthy ( ) ; // prettier-ignore
188
+ expect ( document . body . querySelector ( "main > div > pre code .hljs-keyword" ) ) . toBeTruthy ( ) ; // prettier-ignore
185
189
} ) ;
186
190
} ) ;
187
191
} ) ;
0 commit comments