待测试
This commit is contained in:
@@ -34,22 +34,49 @@ const run = async () => {
|
||||
`;
|
||||
|
||||
const requests = [];
|
||||
const feedResponse = {
|
||||
feedId: "9001",
|
||||
genealogyId: "1001",
|
||||
publisherNickName: "家谱用户",
|
||||
feedType: "photo",
|
||||
feedContent: "family memory",
|
||||
mediaOssIds: "2060000000000000001,2060000000000000002",
|
||||
likedByMe: false,
|
||||
likeCount: 0,
|
||||
commentCount: 0,
|
||||
pinned: "0",
|
||||
createTime: "2026-07-27T10:00:00+08:00",
|
||||
};
|
||||
let response = { statusCode: 200, data: { code: 200, data: feedResponse } };
|
||||
globalThis.uni = {
|
||||
request(options) {
|
||||
requests.push(options);
|
||||
queueMicrotask(() => options.success({ statusCode: 200, data: { code: 200, data: {} } }));
|
||||
queueMicrotask(() => options.success(response));
|
||||
return { abort() {} };
|
||||
},
|
||||
};
|
||||
const { appApi } = await import(toDataModuleUrl(`${prelude}\n${moduleBody}`));
|
||||
|
||||
await appApi.createFeed("1001", {
|
||||
const createdFeed = await appApi.createFeed("1001", {
|
||||
feedType: " photo ",
|
||||
feedContent: " family memory ",
|
||||
mediaOssIds: "2060000000000000001,2060000000000000002",
|
||||
sortOrder: "0",
|
||||
status: " 0 ",
|
||||
});
|
||||
assert.deepStrictEqual(createdFeed, {
|
||||
id: "9001",
|
||||
genealogyId: "1001",
|
||||
content: "family memory",
|
||||
publisher: "家谱用户",
|
||||
type: "photo",
|
||||
time: "2026-07-27T10:00:00+08:00",
|
||||
mediaOssIds: "2060000000000000001,2060000000000000002",
|
||||
likeCount: 0,
|
||||
commentCount: 0,
|
||||
likedByMe: false,
|
||||
pinned: "0",
|
||||
});
|
||||
assert.deepStrictEqual(requests.at(-1).data, {
|
||||
feedType: "photo",
|
||||
feedContent: "family memory",
|
||||
@@ -59,6 +86,7 @@ const run = async () => {
|
||||
});
|
||||
assert.strictEqual(requests.at(-1).url, "https://backend-api.ddxcjp.cn/genealogy/app/genealogies/1001/feeds");
|
||||
|
||||
response = { statusCode: 200, data: { code: 200, data: { ...feedResponse, feedContent: "only required" } } };
|
||||
await appApi.createFeed("1001", { feedContent: "only required" });
|
||||
assert.deepStrictEqual(requests.at(-1).data, { feedContent: "only required" });
|
||||
await assert.rejects(
|
||||
@@ -66,11 +94,17 @@ const run = async () => {
|
||||
/mediaOssIds/,
|
||||
);
|
||||
|
||||
const updatedFeed = await appApi.updateFeed("1001", "9001", { feedContent: "family memory" });
|
||||
assert.strictEqual(updatedFeed.id, "9001");
|
||||
assert.strictEqual(requests.at(-1).method, "PUT");
|
||||
|
||||
response = { statusCode: 200, data: { code: 200, data: {} } };
|
||||
|
||||
await appApi.createArticle("1001", {
|
||||
categoryId: "900040001",
|
||||
articleTitle: " title ",
|
||||
articleSummary: " summary ",
|
||||
coverOssId: 900001,
|
||||
coverOssId: "9007199254740993",
|
||||
articleContent: " body ",
|
||||
authorName: " author ",
|
||||
sortOrder: "1",
|
||||
@@ -80,7 +114,7 @@ const run = async () => {
|
||||
categoryId: 900040001,
|
||||
articleTitle: "title",
|
||||
articleSummary: "summary",
|
||||
coverOssId: 900001,
|
||||
coverOssId: "9007199254740993",
|
||||
articleContent: "body",
|
||||
authorName: "author",
|
||||
sortOrder: 1,
|
||||
@@ -91,21 +125,21 @@ const run = async () => {
|
||||
await appApi.createAlbum("1001", {
|
||||
albumName: " old photos ",
|
||||
albumDesc: " family album ",
|
||||
coverOssId: 900001,
|
||||
coverOssId: "9007199254740993",
|
||||
sortOrder: "1",
|
||||
status: " 0 ",
|
||||
});
|
||||
assert.deepStrictEqual(requests.at(-1).data, {
|
||||
albumName: "old photos",
|
||||
albumDesc: "family album",
|
||||
coverOssId: 900001,
|
||||
coverOssId: "9007199254740993",
|
||||
sortOrder: 1,
|
||||
status: "0",
|
||||
});
|
||||
assert.strictEqual(requests.at(-1).url, "https://backend-api.ddxcjp.cn/genealogy/app/genealogies/1001/albums");
|
||||
await assert.rejects(
|
||||
appApi.createAlbum("1001", { albumName: "bad id", coverOssId: "9007199254740992" }),
|
||||
/coverOssId/,
|
||||
appApi.createAlbum("1001", { albumName: "bad id", coverOssId: 900001 }),
|
||||
/OSS ID 字符串/,
|
||||
);
|
||||
|
||||
delete globalThis.uni;
|
||||
|
||||
Reference in New Issue
Block a user