Skip to content

Commit c1f810e

Browse files
easonliang28easonLiangWorldedtech
authored andcommitted
refactor(Task.spec): simplify mockStreamFactory to standard async generator
1 parent d5394f2 commit c1f810e

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

src/core/task/__tests__/Task.spec.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,25 +2232,10 @@ describe("Cline", () => {
22322232
})
22332233

22342234
let callCount = 0
2235-
const mockStreamFactory = () => {
2236-
return {
2237-
async *[Symbol.asyncIterator]() {
2238-
yield { type: "text", text: `response ${callCount}` }
2239-
},
2240-
async next() {
2241-
callCount++
2242-
return { done: true, value: { type: "text", text: `response ${callCount - 1}` } }
2243-
},
2244-
async return() {
2245-
return { done: true, value: undefined }
2246-
},
2247-
async throw(e: any) {
2248-
throw e
2249-
},
2250-
[Symbol.asyncDispose]: async () => {},
2251-
} as AsyncGenerator<ApiStreamChunk>
2235+
const mockStreamFactory = async function* (): AsyncGenerator<ApiStreamChunk> {
2236+
yield { type: "text", text: `response ${callCount}` }
2237+
callCount++
22522238
}
2253-
22542239
const createMessageSpy = vi
22552240
.spyOn(task.api, "createMessage")
22562241
.mockImplementation(() => mockStreamFactory())

0 commit comments

Comments
 (0)