test: fix wechat-mp test

This commit is contained in:
DIYgod
2024-03-27 14:53:43 +08:00
parent 760f48b8cf
commit 3016a2f44f
2 changed files with 15 additions and 17 deletions
+15
View File
@@ -32,6 +32,21 @@ const server = setupServer(
</li>
</ul>
</div>`)
),
http.get(`https://mp.weixin.qq.com/rsshub_test/wechatMp_fetchArticle`, () =>
HttpResponse.text(
'\n' +
'<meta name="description" content="summary" />\n' +
'<meta name="author" content="author" />\n' +
'<meta property="og:title" content="title" />\n' +
'<meta property="twitter:card" content="summary" />\n' +
'<div class="rich_media_content" id="js_content" style="visibility: hidden;">description</div>\n' +
'<div class="profile_inner"><strong class="profile_nickname">mpName</strong></div>\n' +
'<script type="text/javascript" nonce="000000000">\n' +
'var appmsg_type = "9";\n' +
`var ct = "${1_636_626_300}";\n` +
'</script>'
)
)
);
server.listen();
-17
View File
@@ -1,6 +1,5 @@
import { describe, expect, it } from 'vitest';
import { load } from 'cheerio';
import nock from 'nock';
import { fixArticleContent, fetchArticle, finishArticleItem, normalizeUrl } from '@/utils/wechat-mp';
// date from the cache will be an ISO8601 string, so we need to use this function
@@ -91,22 +90,6 @@ describe('wechat-mp', () => {
it('fetchArticle_&_finishArticleItem', async () => {
const ct = 1_636_626_300;
const exampleMpArticlePage =
'\n' +
'<meta name="description" content="summary" />\n' +
'<meta name="author" content="author" />\n' +
'<meta property="og:title" content="title" />\n' +
'<meta property="twitter:card" content="summary" />\n' +
'<div class="rich_media_content" id="js_content" style="visibility: hidden;">description</div>\n' +
'<div class="profile_inner"><strong class="profile_nickname">mpName</strong></div>\n' +
'<script type="text/javascript" nonce="000000000">\n' +
'var appmsg_type = "9";\n' +
`var ct = "${ct}";\n` +
'</script>';
nock('https://mp.weixin.qq.com')
.get('/rsshub_test/wechatMp_fetchArticle')
.reply(() => [200, exampleMpArticlePage]);
const httpsUrl = 'https://mp.weixin.qq.com/rsshub_test/wechatMp_fetchArticle';
const httpUrl = httpsUrl.replace(/^https:\/\//, 'http://');