1- import cheerio from 'cheerio'
1+ import { load } from 'cheerio'
22import { describe , expect , test } from 'vitest'
33
44import { renderContent } from '@/content-render/index'
@@ -32,7 +32,7 @@ describe('renderContent', () => {
32321. item three` )
3333
3434 const html = await renderContent ( template )
35- const $ = cheerio . load ( html , { xmlMode : true } )
35+ const $ = load ( html , { xmlMode : true } )
3636 expect ( $ ( 'ol' ) . length ) . toBe ( 1 )
3737 expect ( $ ( 'ol > li' ) . length ) . toBe ( 3 )
3838 } )
@@ -43,7 +43,7 @@ describe('renderContent', () => {
4343- <a>item</a>` )
4444
4545 const html = await renderContent ( template )
46- const $ = cheerio . load ( html , { xmlMode : true } )
46+ const $ = load ( html , { xmlMode : true } )
4747 expect ( $ ( 'ul p' ) . length ) . toBe ( 0 )
4848 } )
4949
@@ -69,7 +69,7 @@ describe('renderContent', () => {
6969|<kbd>g</kbd> <kbd>i</kbd> | Go to the **Issues** tab. For more information, see "[About issues](/articles/about-issues)."
7070 ` )
7171 const html = await renderContent ( template )
72- const $ = cheerio . load ( html , { xmlMode : true } )
72+ const $ = load ( html , { xmlMode : true } )
7373 expect (
7474 $ . html ( ) . includes ( '"<a href="/articles/about-issues">About issues</a>."' ) ,
7575 ) . toBeTruthy ( )
@@ -82,7 +82,7 @@ describe('renderContent', () => {
8282| Python | \`requirements.txt\`, \`pipfile.lock\`
8383 ` )
8484 const html = await renderContent ( template )
85- const $ = cheerio . load ( html , { xmlMode : true } )
85+ const $ = load ( html , { xmlMode : true } )
8686 expect (
8787 $ . html ( ) . includes ( '<code>requirements.txt</code>, <code>pipfile.lock</code>' ) ,
8888 ) . toBeTruthy ( )
@@ -95,7 +95,7 @@ describe('renderContent', () => {
9595| <code>user:<em>USERNAME</em></code> | [**user:defunkt ubuntu**](https://github.com/search?q=user%3Adefunkt+ubuntu&type=Issues) matches issues with the word "ubuntu" from repositories owned by @defunkt.
9696 ` )
9797 const html = await renderContent ( template )
98- const $ = cheerio . load ( html , { xmlMode : true } )
98+ const $ = load ( html , { xmlMode : true } )
9999 expect ( $ . html ( ) . includes ( '<code>user:<em>USERNAME</em></code>' ) ) . toBeTruthy ( )
100100 } )
101101
@@ -110,7 +110,7 @@ describe('renderContent', () => {
1101101. This is another list item.
111111 ` )
112112 const html = await renderContent ( template )
113- const $ = cheerio . load ( html , { xmlMode : true } )
113+ const $ = load ( html , { xmlMode : true } )
114114 expect ( $ ( 'ol' ) . length ) . toBe ( 1 )
115115 expect ( $ . html ( ) . includes ( '<span class="hljs-meta prompt_"># </span' ) ) . toBeTruthy ( )
116116 expect ( $ . html ( ) . includes ( 'some comment here' ) ) . toBeTruthy ( )
@@ -131,7 +131,7 @@ describe('renderContent', () => {
131131##### This is a level 5
132132` )
133133 const html = await renderContent ( template )
134- const $ = cheerio . load ( html , { xmlMode : true } )
134+ const $ = load ( html , { xmlMode : true } )
135135
136136 for ( const level of [ 1 , 2 , 3 , 4 , 5 ] ) {
137137 expect (
@@ -147,7 +147,7 @@ const example = true
147147\`\`\`\`
148148 ` )
149149 let html = await renderContent ( template )
150- let $ = cheerio . load ( html , { xmlMode : true } )
150+ let $ = load ( html , { xmlMode : true } )
151151 expect ( $ . html ( ) . includes ( '<pre><code class="hljs language-js">' ) ) . toBeTruthy ( )
152152 expect ( $ . html ( ) . includes ( '<span class="hljs-keyword">const</span>' ) ) . toBeTruthy ( )
153153
@@ -157,7 +157,7 @@ const example = true
157157\`\`\`\`
158158 ` )
159159 html = await renderContent ( template )
160- $ = cheerio . load ( html , { xmlMode : true } )
160+ $ = load ( html , { xmlMode : true } )
161161 expect ( $ . html ( ) . includes ( '<pre><code class="hljs language-erb">' ) ) . toBeTruthy ( )
162162 expect ( $ . html ( ) . includes ( '<span class="hljs-variable">@articles</span>' ) ) . toBeTruthy ( )
163163
@@ -167,7 +167,7 @@ POST / HTTP/2
167167\`\`\`\`
168168 ` )
169169 html = await renderContent ( template )
170- $ = cheerio . load ( html , { xmlMode : true } )
170+ $ = load ( html , { xmlMode : true } )
171171 expect ( $ . html ( ) . includes ( '<pre><code class="hljs language-http">' ) ) . toBeTruthy ( )
172172 expect ( $ . html ( ) . includes ( '<span class="hljs-keyword">POST</span>' ) ) . toBeTruthy ( )
173173
@@ -180,7 +180,7 @@ plugins {
180180\`\`\`\`
181181 ` )
182182 html = await renderContent ( template )
183- $ = cheerio . load ( html , { xmlMode : true } )
183+ $ = load ( html , { xmlMode : true } )
184184 expect ( $ . html ( ) . includes ( '<pre><code class="hljs language-groovy">' ) ) . toBeTruthy ( )
185185 expect (
186186 $ . html ( ) . includes ( '<span class="hljs-string">'maven-publish'</span>' ) ,
@@ -192,7 +192,7 @@ FROM alpine:3.10
192192\`\`\`\`
193193 ` )
194194 html = await renderContent ( template )
195- $ = cheerio . load ( html , { xmlMode : true } )
195+ $ = load ( html , { xmlMode : true } )
196196 expect ( $ . html ( ) . includes ( '<pre><code class="hljs language-Dockerfile">' ) ) . toBeTruthy ( )
197197 expect ( $ . html ( ) . includes ( '<span class="hljs-keyword">FROM</span>' ) ) . toBeTruthy ( )
198198
@@ -202,7 +202,7 @@ $resourceGroupName = "octocat-testgroup"
202202\`\`\`\`
203203 ` )
204204 html = await renderContent ( template )
205- $ = cheerio . load ( html , { xmlMode : true } )
205+ $ = load ( html , { xmlMode : true } )
206206 expect ( $ . html ( ) . includes ( '<pre><code class="hljs language-Powershell">' ) ) . toBeTruthy ( )
207207 expect (
208208 $ . html ( ) . includes ( '<span class="hljs-variable">$resourceGroupName</span>' ) ,
@@ -216,7 +216,7 @@ var a = 1
216216\`\`\`
217217 ` )
218218 const html = await renderContent ( template )
219- const $ = cheerio . load ( html , { xmlMode : true } )
219+ const $ = load ( html , { xmlMode : true } )
220220 expect ( $ . html ( ) . includes ( 'var a = 1' ) ) . toBeTruthy ( )
221221 } )
222222
@@ -238,7 +238,7 @@ var a = 1
238238\`\`\`
239239 ` )
240240 const html = await renderContent ( template )
241- const $ = cheerio . load ( html )
241+ const $ = load ( html )
242242 const el = $ ( 'button.js-btn-copy' )
243243 expect ( el . data ( 'clipboard' ) ) . toBe ( 2967273189 )
244244 // Generates a murmurhash based ID that matches a <pre>
@@ -250,7 +250,7 @@ var a = 1
250250> This is a note with a [link](https://example.com)
251251 ` )
252252 const html = await renderContent ( template , { alertTitles : { NOTE : 'Note' } } )
253- const $ = cheerio . load ( html )
253+ const $ = load ( html )
254254 const alertEl = $ ( '.ghd-alert' )
255255 expect ( alertEl . length ) . toBe ( 1 )
256256 expect ( alertEl . attr ( 'data-container' ) ) . toBe ( 'alert' )
0 commit comments