待测试
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("assert");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const toDataModuleUrl = (source) =>
|
||||
`data:text/javascript;base64,${Buffer.from(source).toString("base64")}`;
|
||||
|
||||
const run = async () => {
|
||||
const rawSource = fs.readFileSync(path.join(__dirname, "../utils/api.js"), "utf8");
|
||||
const moduleBody = rawSource.slice(rawSource.indexOf("const successCodes"));
|
||||
const prelude = `
|
||||
const currentUser = {};
|
||||
const genealogies = [];
|
||||
const publicGenealogies = [];
|
||||
const treeMembers = [];
|
||||
const notifications = [];
|
||||
const joinApplications = [];
|
||||
const listFamilyFeedFixtures = () => [];
|
||||
const listFamilyArticleFixtures = () => [];
|
||||
const listFamilyAlbumFixtures = () => [];
|
||||
const listCeremonyFixtures = () => [];
|
||||
const listGrowthRecordFixtures = () => [];
|
||||
const listNotificationFixtures = () => [];
|
||||
const runtimeConfig = { baseUrl: "https://backend-api.ddxcjp.cn", clientId: "client-1", tenantId: "000000" };
|
||||
const hasRemoteConfig = () => true;
|
||||
const resolveRuntimeMode = () => "remote";
|
||||
const AUTH_TAC_SCENE = Object.freeze({});
|
||||
const assertSmsCode = (value) => value;
|
||||
const GENEALOGY_ACCESS_PRESET = Object.freeze({ MEMBER_ONLY: "MEMBER_ONLY" });
|
||||
const fromApiGenealogyAccess = () => null;
|
||||
const session = { getToken: () => "session-1", saveToken() {} };
|
||||
`;
|
||||
|
||||
const requests = [];
|
||||
let response;
|
||||
globalThis.uni = {
|
||||
request(options) {
|
||||
requests.push(options);
|
||||
queueMicrotask(() => options.success(response));
|
||||
return { abort() {} };
|
||||
},
|
||||
};
|
||||
const { appApi } = await import(toDataModuleUrl(`${prelude}\n${moduleBody}`));
|
||||
const detail = {
|
||||
notificationId: "900001",
|
||||
genealogyId: "1001",
|
||||
genealogyNo: "J-1001",
|
||||
genealogyName: "王氏家谱",
|
||||
senderUserId: "101",
|
||||
senderNickName: "管理员",
|
||||
senderPhone: "138****8000",
|
||||
noticeType: "SYSTEM",
|
||||
noticeTitle: "审核完成",
|
||||
noticeContent: "您的申请已审核完成。",
|
||||
bizType: "APPLICATION",
|
||||
bizId: "3001",
|
||||
bizSummary: "入谱申请",
|
||||
publishTime: "2026-07-27T08:00:00+08:00",
|
||||
readStatus: "0",
|
||||
readTime: null,
|
||||
status: "0",
|
||||
remark: "",
|
||||
};
|
||||
|
||||
response = { statusCode: 200, data: { code: 200, data: detail } };
|
||||
const result = await appApi.getNotificationDetail("900001");
|
||||
assert.strictEqual(requests.at(-1).url, "https://backend-api.ddxcjp.cn/genealogy/app/notifications/900001");
|
||||
assert.strictEqual(requests.at(-1).method, "GET");
|
||||
assert.strictEqual(result.notificationId, "900001");
|
||||
assert.strictEqual(result.noticeTitle, "审核完成");
|
||||
assert.strictEqual(result.genealogyId, "1001");
|
||||
assert.strictEqual(result.readTime, "");
|
||||
|
||||
response = { statusCode: 200, data: { code: 200, data: { ...detail, notificationId: "900002" } } };
|
||||
await assert.rejects(appApi.getNotificationDetail("900001"), (error) => error.code === "NOTIFICATION_DETAIL_RESPONSE_INVALID");
|
||||
await assert.rejects(appApi.getNotificationDetail("invalid"), /正整数/);
|
||||
|
||||
delete globalThis.uni;
|
||||
process.stdout.write("NOTIFICATION-DETAIL-API-RUNTIME-SMOKE PASS\n");
|
||||
};
|
||||
|
||||
run().catch((error) => {
|
||||
process.stderr.write(`${error.stack || error.message}\n`);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user