|
|
@@ -0,0 +1,567 @@
|
|
|
+import { describe, it, expect, beforeEach } from 'vitest';
|
|
|
+import { testClient } from 'hono/testing';
|
|
|
+import { IntegrationTestDatabase, setupIntegrationDatabaseHooksWithEntities } from '@d8d/shared-test-util';
|
|
|
+import { JWTUtil } from '@d8d/shared-utils';
|
|
|
+import { UserEntity, Role } from '@d8d/user-module';
|
|
|
+import { File } from '@d8d/file-module';
|
|
|
+import { Platform } from '@d8d/allin-platform-module/entities';
|
|
|
+import companyRoutes from '../../src/routes/company.routes';
|
|
|
+import { Company } from '../../src/entities/company.entity';
|
|
|
+
|
|
|
+// 设置集成测试钩子 - 需要包含Platform实体
|
|
|
+setupIntegrationDatabaseHooksWithEntities([UserEntity, File, Role, Platform, Company])
|
|
|
+
|
|
|
+describe('公司管理API集成测试', () => {
|
|
|
+ let client: ReturnType<typeof testClient<typeof companyRoutes>>;
|
|
|
+ let testToken: string;
|
|
|
+ let testUser: UserEntity;
|
|
|
+ let testPlatform: Platform;
|
|
|
+
|
|
|
+ beforeEach(async () => {
|
|
|
+ // 创建测试客户端
|
|
|
+ client = testClient(companyRoutes);
|
|
|
+
|
|
|
+ // 获取数据源
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+
|
|
|
+ // 创建测试用户
|
|
|
+ const userRepository = dataSource.getRepository(UserEntity);
|
|
|
+ testUser = userRepository.create({
|
|
|
+ username: `test_user_${Date.now()}`,
|
|
|
+ password: 'test_password',
|
|
|
+ nickname: '测试用户',
|
|
|
+ registrationSource: 'web'
|
|
|
+ });
|
|
|
+ await userRepository.save(testUser);
|
|
|
+
|
|
|
+ // 生成测试用户的token
|
|
|
+ testToken = JWTUtil.generateToken({
|
|
|
+ id: testUser.id,
|
|
|
+ username: testUser.username,
|
|
|
+ roles: [{name:'user'}]
|
|
|
+ });
|
|
|
+
|
|
|
+ // 创建测试平台
|
|
|
+ const platformRepository = dataSource.getRepository(Platform);
|
|
|
+ testPlatform = platformRepository.create({
|
|
|
+ platformName: `测试平台_${Date.now()}`,
|
|
|
+ contactPerson: '平台管理员',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ contactEmail: 'admin@example.com',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await platformRepository.save(testPlatform);
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('POST /company/createCompany', () => {
|
|
|
+ it('应该成功创建公司', async () => {
|
|
|
+ const createData = {
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '示例科技有限公司',
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ contactEmail: 'zhangsan@example.com',
|
|
|
+ address: '北京市朝阳区'
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await client.createCompany.$post({
|
|
|
+ json: createData
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.debug('创建公司响应状态:', response.status);
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data.success).toBe(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ it('应该验证公司名称在同一平台下重复', async () => {
|
|
|
+ // 先创建一个公司
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+ const existingCompany = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '示例科技有限公司',
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(existingCompany);
|
|
|
+
|
|
|
+ // 尝试创建同名公司(同一平台下)
|
|
|
+ const createData = {
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '示例科技有限公司', // 重复的名称
|
|
|
+ contactPerson: '李四',
|
|
|
+ contactPhone: '13900139000'
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await client.createCompany.$post({
|
|
|
+ json: createData
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(response.status).toBe(400);
|
|
|
+ if (response.status === 400) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data.message).toContain('公司名称在该平台下已存在');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ it('应该允许不同平台下的相同公司名称', async () => {
|
|
|
+ // 创建第二个平台
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const platformRepository = dataSource.getRepository(Platform);
|
|
|
+ const secondPlatform = platformRepository.create({
|
|
|
+ platformName: `第二测试平台_${Date.now()}`,
|
|
|
+ contactPerson: '第二平台管理员',
|
|
|
+ contactPhone: '13900139000',
|
|
|
+ contactEmail: 'admin2@example.com',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await platformRepository.save(secondPlatform);
|
|
|
+
|
|
|
+ // 在第一个平台下创建公司
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+ const existingCompany = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '示例科技有限公司',
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(existingCompany);
|
|
|
+
|
|
|
+ // 在第二个平台下创建同名公司(应该允许)
|
|
|
+ const createData = {
|
|
|
+ platformId: secondPlatform.id,
|
|
|
+ companyName: '示例科技有限公司', // 相同名称,不同平台
|
|
|
+ contactPerson: '李四',
|
|
|
+ contactPhone: '13900139000'
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await client.createCompany.$post({
|
|
|
+ json: createData
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data.success).toBe(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ it('应该拒绝未认证用户的访问', async () => {
|
|
|
+ const createData = {
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '测试公司',
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000'
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await client.createCompany.$post({
|
|
|
+ json: createData
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(response.status).toBe(401);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('POST /company/deleteCompany', () => {
|
|
|
+ it('应该成功删除公司(软删除)', async () => {
|
|
|
+ // 先创建一个公司
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+ const testCompany = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: `待删除公司_${Date.now()}`,
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(testCompany);
|
|
|
+
|
|
|
+ const deleteData = {
|
|
|
+ id: testCompany.id
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await client.deleteCompany.$post({
|
|
|
+ json: deleteData
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.debug('删除公司响应状态:', response.status);
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data.success).toBe(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证公司状态变为0(软删除)
|
|
|
+ const deletedCompany = await companyRepository.findOne({
|
|
|
+ where: { id: testCompany.id }
|
|
|
+ });
|
|
|
+ expect(deletedCompany?.status).toBe(0);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('POST /company/updateCompany', () => {
|
|
|
+ it('应该成功更新公司', async () => {
|
|
|
+ // 先创建一个公司
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+ const testCompany = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: `原始公司_${Date.now()}`,
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(testCompany);
|
|
|
+
|
|
|
+ const updateData = {
|
|
|
+ id: testCompany.id,
|
|
|
+ companyName: '更新后的公司名称',
|
|
|
+ contactPerson: '李四',
|
|
|
+ contactPhone: '13900139000'
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await client.updateCompany.$post({
|
|
|
+ json: updateData
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.debug('更新公司响应状态:', response.status);
|
|
|
+
|
|
|
+ if (response.status !== 200) {
|
|
|
+ const errorData = await response.json();
|
|
|
+ console.debug('更新公司错误:', errorData);
|
|
|
+ }
|
|
|
+
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data.success).toBe(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证公司已更新
|
|
|
+ const updatedCompany = await companyRepository.findOne({
|
|
|
+ where: { id: testCompany.id }
|
|
|
+ });
|
|
|
+ expect(updatedCompany?.companyName).toBe(updateData.companyName);
|
|
|
+ expect(updatedCompany?.contactPerson).toBe(updateData.contactPerson);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('应该验证更新时的公司名称在同一平台下重复', async () => {
|
|
|
+ // 创建两个公司
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+
|
|
|
+ const company1 = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '公司A',
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(company1);
|
|
|
+
|
|
|
+ const company2 = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '公司B',
|
|
|
+ contactPerson: '李四',
|
|
|
+ contactPhone: '13900139000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(company2);
|
|
|
+
|
|
|
+ // 尝试将公司B的名称改为公司A的名称(同一平台下)
|
|
|
+ const updateData = {
|
|
|
+ id: company2.id,
|
|
|
+ companyName: '公司A' // 重复的名称
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await client.updateCompany.$post({
|
|
|
+ json: updateData
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(response.status).toBe(400);
|
|
|
+ if (response.status === 400) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data.message).toContain('公司名称在该平台下已存在');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ it('应该允许更新到不同平台下的相同名称', async () => {
|
|
|
+ // 创建第二个平台
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const platformRepository = dataSource.getRepository(Platform);
|
|
|
+ const secondPlatform = platformRepository.create({
|
|
|
+ platformName: `第二测试平台_${Date.now()}`,
|
|
|
+ contactPerson: '第二平台管理员',
|
|
|
+ contactPhone: '13900139000',
|
|
|
+ contactEmail: 'admin2@example.com',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await platformRepository.save(secondPlatform);
|
|
|
+
|
|
|
+ // 创建两个公司,分别在不同平台下
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+
|
|
|
+ const company1 = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '公司A',
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(company1);
|
|
|
+
|
|
|
+ const company2 = companyRepository.create({
|
|
|
+ platformId: secondPlatform.id,
|
|
|
+ companyName: '公司B',
|
|
|
+ contactPerson: '李四',
|
|
|
+ contactPhone: '13900139000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(company2);
|
|
|
+
|
|
|
+ // 将公司B的名称改为公司A的名称,但保持平台为第二个平台(应该允许,因为不同平台下可以有相同名称)
|
|
|
+ const updateData = {
|
|
|
+ id: company2.id,
|
|
|
+ companyName: '公司A',
|
|
|
+ platformId: secondPlatform.id // 保持第二个平台
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await client.updateCompany.$post({
|
|
|
+ json: updateData
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data.success).toBe(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('GET /company/getAllCompanies', () => {
|
|
|
+ it('应该返回公司列表(包含平台关联信息)', async () => {
|
|
|
+ // 创建一些测试公司
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+
|
|
|
+ for (let i = 0; i < 3; i++) {
|
|
|
+ const company = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: `测试公司${i}`,
|
|
|
+ contactPerson: `联系人${i}`,
|
|
|
+ contactPhone: `1380013800${i}`,
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(company);
|
|
|
+ }
|
|
|
+
|
|
|
+ const response = await client.getAllCompanies.$get({
|
|
|
+ query: { skip: 0, take: 10 }
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.debug('公司列表响应状态:', response.status);
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data).toHaveProperty('data');
|
|
|
+ expect(data).toHaveProperty('total');
|
|
|
+ expect(Array.isArray(data.data)).toBe(true);
|
|
|
+ expect(data.total).toBeGreaterThanOrEqual(3);
|
|
|
+
|
|
|
+ // 验证返回的数据包含平台关联信息
|
|
|
+ if (data.data.length > 0) {
|
|
|
+ expect(data.data[0]).toHaveProperty('platform');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ it('应该支持分页参数', async () => {
|
|
|
+ const response = await client.getAllCompanies.$get({
|
|
|
+ query: { skip: 0, take: 5 }
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('GET /company/searchCompanies', () => {
|
|
|
+ it('应该按名称搜索公司', async () => {
|
|
|
+ // 创建测试公司
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+
|
|
|
+ const company = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '科技公司搜索测试',
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(company);
|
|
|
+
|
|
|
+ const response = await client.searchCompanies.$get({
|
|
|
+ query: { name: '科技', skip: 0, take: 10 }
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.debug('搜索公司响应状态:', response.status);
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data.data.length).toBeGreaterThan(0);
|
|
|
+ expect(data.data[0].companyName).toContain('科技');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('GET /company/getCompaniesByPlatform/:platformId', () => {
|
|
|
+ it('应该按平台ID查询公司', async () => {
|
|
|
+ // 创建测试公司
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+
|
|
|
+ const company = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: '平台关联测试公司',
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(company);
|
|
|
+
|
|
|
+ const response = await client.getCompaniesByPlatform[':platformId'].$get({
|
|
|
+ param: { platformId: testPlatform.id }
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.debug('按平台查询公司响应状态:', response.status);
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(Array.isArray(data)).toBe(true);
|
|
|
+ expect(data.length).toBeGreaterThan(0);
|
|
|
+ expect(data[0].platformId).toBe(testPlatform.id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ it('应该处理不存在的平台ID', async () => {
|
|
|
+ const response = await client.getCompaniesByPlatform[':platformId'].$get({
|
|
|
+ param: { platformId: 999999 }
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(Array.isArray(data)).toBe(true);
|
|
|
+ expect(data.length).toBe(0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('GET /company/getCompany/:id', () => {
|
|
|
+ it('应该返回指定公司的详情(包含平台关联信息)', async () => {
|
|
|
+ // 先创建一个公司
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
+ const testCompany = companyRepository.create({
|
|
|
+ platformId: testPlatform.id,
|
|
|
+ companyName: `详情测试公司_${Date.now()}`,
|
|
|
+ contactPerson: '张三',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ await companyRepository.save(testCompany);
|
|
|
+
|
|
|
+ const response = await client.getCompany[':id'].$get({
|
|
|
+ param: { id: testCompany.id }
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.debug('公司详情响应状态:', response.status);
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+
|
|
|
+ if (response.status === 200) {
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data!.id).toBe(testCompany.id);
|
|
|
+ expect(data!.companyName).toBe(testCompany.companyName);
|
|
|
+ expect(data!.platformId).toBe(testPlatform.id);
|
|
|
+ // 验证包含平台关联信息
|
|
|
+ expect(data!).toHaveProperty('platform');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ it('应该处理不存在的公司', async () => {
|
|
|
+ const response = await client.getCompany[':id'].$get({
|
|
|
+ param: { id: 999999 }
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(response.status).toBe(200);
|
|
|
+ const data = await response.json();
|
|
|
+ expect(data).toBeNull();
|
|
|
+ });
|
|
|
+ });
|
|
|
+});
|