From 8fa16d9b14e10224d2a7e7fabf150c8450e27c30 Mon Sep 17 00:00:00 2001 From: jing <1683105490@qq.com> Date: Mon, 19 Oct 2026 10:12:44 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=E4=BF=9D=E7=95=99test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/card-api.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/card-api.test.js b/tests/card-api.test.js index 74e4485..8d52b89 100644 --- a/tests/card-api.test.js +++ b/tests/card-api.test.js @@ -41,6 +41,7 @@ const DOC_URLS = [ '/card/api/card/lists', '/card/api/card/detail', '/card/api/card/update', + '/card/api/card/toggleFavorite', // 收藏(双向 toggle, 后端 2.9.12) '/card/api/card/create', // 后端源码已有(新建数字名片), 旧文档未列, 以源码为准 '/card/api/card/claim', '/card/api/card/recognize', @@ -73,6 +74,7 @@ const HELPER_URL_PAIRS = [ ['cardLists', 'CARD_LISTS'], ['cardDetail', 'CARD_DETAIL'], ['cardUpdate', 'CARD_UPDATE'], + ['cardToggleFavorite', 'CARD_FAVORITE'], ['cardCreate', 'CARD_CREATE'], ['cardClaim', 'CARD_CLAIM'], ['cardRecognize', 'CARD_RECOGNIZE'], @@ -98,7 +100,7 @@ const HELPER_URL_PAIRS = [ ]; // 文档 3.3/4.2/4.4/3.7: 嵌套对象/数组入参必须走 JSON body(sendJson) -const JSON_BODY_HELPERS = ['cardUpdate', 'cardCreate', 'contactAdd', 'contactUpdate', 'cardRecognizeBatch', 'exchangeAgree', 'exchangeIgnore', 'cardDesignSave']; +const JSON_BODY_HELPERS = ['cardUpdate', 'cardCreate', 'cardToggleFavorite', 'contactAdd', 'contactUpdate', 'cardRecognizeBatch', 'exchangeAgree', 'exchangeIgnore', 'cardDesignSave']; // ============================================================= // 1. 端点与后端文档逐一比对 @@ -126,7 +128,7 @@ test('收口: 15 个端点均有对应 helper 方法', () => { for (const [helper, urlConst] of HELPER_URL_PAIRS) { assert.ok(new RegExp(`\\b${helper}\\(p\\)\\s*\\{`).test(API_SRC), `缺少 helper ${helper}(p)`); - assert.ok(new RegExp(`url:\\s*CARD_API_URL\\.${urlConst}\\b`).test(API_SRC), + assert.ok(new RegExp(`(?:url\\s*:|url\\s*=)\\s*CARD_API_URL\\.${urlConst}\\b`).test(API_SRC), `helper ${helper} 未绑定 ${urlConst}`); } });