@@ -16,15 +16,15 @@ describe("pat-markdown", function () {
1616 afterEach ( ( ) => {
1717 jest . restoreAllMocks ( ) ;
1818 } ) ;
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 ( ) {
2020 var $el = $ ( '<p class="pat-markdown"></p>' ) ;
2121 $el . appendTo ( "#lab" ) ;
2222 jest . spyOn ( pattern . prototype , "render" ) . mockImplementation ( ( ) => {
2323 return $ ( "<p>Rendering</p>" ) ;
2424 } ) ;
2525 pattern . init ( $el ) ;
2626 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>" ) ;
2828 } ) ;
2929
3030 it ( "It does not render when the DOM element doesn't have the pattern trigger" , function ( ) {
@@ -162,26 +162,30 @@ describe("pat-markdown", function () {
162162
163163 describe ( "Code blocks" , function ( ) {
164164 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">
166168# Title
167169
168170some content
169171
170172\`\`\`javascript
171173 const foo = "bar";
172174\`\`\`
173- </div>
174- ` ;
175+
176+ </div>
177+ </main>
178+ ` ;
175179
176180 new pattern ( document . querySelector ( ".pat-markdown" ) ) ;
177181 await utils . timeout ( 1 ) ; // wait a tick for async to settle.
178182 await utils . timeout ( 1 ) ; // wait a tick for async to settle.
179183
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
185189 } ) ;
186190 } ) ;
187191} ) ;
0 commit comments