Skip to content

Commit

Permalink
test: fix testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
gcfeng committed Feb 5, 2025
1 parent 7b99007 commit 64dcb71
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze/taro-api",
"comment": "fix testcase",
"type": "patch"
}
],
"packageName": "@coze/taro-api",
"email": "[email protected]"
}
3 changes: 1 addition & 2 deletions packages/coze-taro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
},
"license": "MIT",
"author": "yjfengwen <[email protected]>",
"type": "module",
"main": "src/index.ts",
"module": "src/index.ts",
"types": "src/index.ts",
Expand Down Expand Up @@ -62,4 +61,4 @@
"module": "dist/index.js",
"types": "dist/index.d.ts"
}
}
}
2 changes: 1 addition & 1 deletion packages/coze-taro/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class CozeAPI extends InnerCozeAPI {
header,
success: res => {
// Request failed
if (res.statusCode !== 200 || res.data.code) {
if (res.statusCode !== 200 || res.data?.code) {
const resData = res.data || {};
resData.error = resData.error || resData.detail || {};
const resHeader = res.header || {};
Expand Down
10 changes: 0 additions & 10 deletions packages/coze-taro/test/api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import { CozeAPI } from '../src/api';

vi.mock('../src/mixins/platform', async () => {
const mod = await vi.importActual('../src/mixins/platform.weapp');
return mod;
});

vi.mock('../src/event-source/index', async () => {
const mod = await vi.importActual('../src/event-source/index.weapp');
return mod;
});

describe('CozeAPI - mini', () => {
beforeEach(() => {
vi.useFakeTimers();
Expand Down
2 changes: 1 addition & 1 deletion packages/coze-taro/test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const taroRequest = ({
success: (res: { statusCode: number; errMsg?: string }) => void;
}) => {
if (data?.workflow_id === 'nonStreaming') {
return Promise.resolve();
return Promise.resolve({ statusCode: 200 });
}

const task = new TaroStreamingTask();
Expand Down

0 comments on commit 64dcb71

Please sign in to comment.