UNPKG

pocketbase-tools

Version:

A TypeScript toolkit for PocketBase, featuring a standard service/action/types layered structure. It provides interfaces and implementations for common business logic such as users, products, company profiles, and file utilities, making it suitable for se

38 lines (37 loc) 1.55 kB
import assert from "assert"; import testLoginAdmin from "."; import { profileAction, profileService } from "../services"; (async () => { let createdId = ""; await testLoginAdmin(); // 创建表结构(如未存在) const exists = await profileService.checkProfileCollectionExists(); if (!exists) { const result = await profileAction.createProfileCollection(); assert(result, "表结构创建失败"); } // 添加公司资料 const profile = { companyName: "测试公司", contactEmail: "test@company.com", contactPhone: "123456789", companyAddress: "测试地址", allowRegistration: true, }; const created = await profileAction.addCompanyProfile(profile); assert(created && created.companyName === "测试公司", "公司资料创建失败"); createdId = created.id; // 查询所有公司资料 const list = await profileService.listAllCompanyProfiles(); assert(Array.isArray(list), "公司资料列表应为数组"); assert(list.find((p) => p.companyName === "测试公司"), "公司资料未出现在列表中"); // 更新公司资料 const updated = await profileAction.updateCompanyProfile(createdId, { companyName: "新公司名", }); assert(updated, "公司资料更新失败"); // 删除公司资料 const deleted = await profileAction.deleteCompanyProfile(createdId); assert(deleted, "公司资料删除失败"); console.log("profile.assert.test.ts 所有断言通过"); })();