|
|
@@ -94,8 +94,8 @@ describe('公开随机商品API集成测试', () => {
|
|
|
price: 100.00,
|
|
|
costPrice: 80.00,
|
|
|
categoryId1: testCategory1.id,
|
|
|
- categoryId2: 0,
|
|
|
- categoryId3: 0,
|
|
|
+ categoryId2: testCategory1.id,
|
|
|
+ categoryId3: testCategory1.id,
|
|
|
goodsType: 1,
|
|
|
supplierId: testSupplier.id,
|
|
|
merchantId: testMerchant.id,
|
|
|
@@ -111,8 +111,8 @@ describe('公开随机商品API集成测试', () => {
|
|
|
price: 200.00,
|
|
|
costPrice: 160.00,
|
|
|
categoryId1: testCategory2.id,
|
|
|
- categoryId2: 0,
|
|
|
- categoryId3: 0,
|
|
|
+ categoryId2: testCategory2.id,
|
|
|
+ categoryId3: testCategory2.id,
|
|
|
goodsType: 1,
|
|
|
supplierId: testSupplier.id,
|
|
|
merchantId: testMerchant.id,
|
|
|
@@ -128,8 +128,8 @@ describe('公开随机商品API集成测试', () => {
|
|
|
price: 300.00,
|
|
|
costPrice: 240.00,
|
|
|
categoryId1: testCategory1.id,
|
|
|
- categoryId2: 0,
|
|
|
- categoryId3: 0,
|
|
|
+ categoryId2: testCategory1.id,
|
|
|
+ categoryId3: testCategory1.id,
|
|
|
goodsType: 2,
|
|
|
supplierId: testSupplier.id,
|
|
|
merchantId: testMerchant.id,
|
|
|
@@ -146,8 +146,8 @@ describe('公开随机商品API集成测试', () => {
|
|
|
price: 400.00,
|
|
|
costPrice: 320.00,
|
|
|
categoryId1: testCategory1.id,
|
|
|
- categoryId2: 0,
|
|
|
- categoryId3: 0,
|
|
|
+ categoryId2: testCategory1.id,
|
|
|
+ categoryId3: testCategory1.id,
|
|
|
goodsType: 1,
|
|
|
supplierId: testSupplier.id,
|
|
|
merchantId: testMerchant.id,
|
|
|
@@ -199,25 +199,6 @@ describe('公开随机商品API集成测试', () => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- it('应该支持按分类过滤', async () => {
|
|
|
- const response = await client.index.$get({
|
|
|
- query: { categoryId: testCategory1.id }
|
|
|
- });
|
|
|
-
|
|
|
- expect(response.status).toBe(200);
|
|
|
-
|
|
|
- if (response.status === 200) {
|
|
|
- const data = await response.json();
|
|
|
- expect(Array.isArray(data.data)).toBe(true);
|
|
|
-
|
|
|
- // 验证只返回指定分类的商品
|
|
|
- data.data.forEach((goods: any) => {
|
|
|
- expect(goods.categoryId1).toBe(testCategory1.id);
|
|
|
- expect(goods.state).toBe(1);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
it('应该支持限制返回数量', async () => {
|
|
|
const response = await client.index.$get({
|
|
|
query: { limit: 2 }
|