Created
December 21, 2024 04:23
-
-
Save YonatanKra/45834eff4b77819ff7fb87f493161447 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should stream posts with done set to false when cursor is truthy', async () => { | |
const spy = vi.fn(); | |
queueAgentFeedResponse(fullFeedResponse); | |
queueAgentFeedResponse(fullFeedResponse); | |
queueAgentFeedResponse(fullFeedLastResponse); | |
await bot.streamPosts(handle, spy); | |
expect(spy.mock.calls[0][0]) | |
.toEqual({result: fullFeedResponse.data.feed, done: false}); | |
expect(spy.mock.calls[1][0]) | |
.toEqual({result: fullFeedResponse.data.feed, done: false}); | |
expect(spy.mock.calls[2][0]) | |
.toEqual({result: fullFeedLastResponse.data.feed, done: true}); | |
}); | |
it('should send done true to callback when response cursor is empty', async () => { | |
const spy = vi.fn(); | |
queueAgentFeedResponse(fullFeedLastResponse); | |
await bot.streamPosts(handle, spy); | |
expect(spy.mock.calls[0][0]) | |
.toEqual({result: fullFeedLastResponse.data.feed, done: true}); | |
}); | |
it('should send done true to callback when feed returns empty', async () => { | |
const spy = vi.fn(); | |
queueAgentFeedResponse(emptyFeedResponse); | |
await bot.streamPosts(handle, spy); | |
expect(spy.mock.calls[0][0]).toEqual({ done: true }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment