Skip to content

Commit eed9040

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/js-sdk-audit-6x115l-m11a-paginator-validation
# Conflicts: # src/lib/seam-paginator.ts
2 parents 0743674 + a6b5769 commit eed9040

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

‎test/seam/connect/seam-paginator.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,40 @@ test('SeamPaginator: flatten allows iteration over all devices', async (t) => {
9696

9797
const expectType = <Expected>(_value: Expected): void => {}
9898

99+
test('SeamPaginator: sends the page cursor when the request has no parameters', async (t) => {
100+
const { seed, endpoint } = await getTestServer(t)
101+
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
102+
103+
nock(endpoint)
104+
.get('/devices/list')
105+
.reply(200, {
106+
devices: [{ device_id: 'device-1' }],
107+
pagination: {
108+
has_next_page: true,
109+
next_page_cursor: 'page-cursor-1',
110+
next_page_url: `${endpoint}/devices/list?page_cursor=page-cursor-1`,
111+
},
112+
})
113+
.get('/devices/list')
114+
.query({ page_cursor: 'page-cursor-1', _strict: 'true' })
115+
.reply(200, {
116+
devices: [{ device_id: 'device-2' }],
117+
pagination: {
118+
has_next_page: false,
119+
next_page_cursor: null,
120+
next_page_url: null,
121+
},
122+
})
123+
124+
const pages = seam.createPaginator(seam.devices.list())
125+
const devices = await pages.flattenToArray()
126+
127+
t.deepEqual(
128+
devices.map(({ device_id: deviceId }) => deviceId),
129+
['device-1', 'device-2'],
130+
)
131+
})
132+
99133
test('SeamPaginator: stops iterating when the page cursor repeats', async (t) => {
100134
const { seed, endpoint } = await getTestServer(t)
101135
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })

0 commit comments

Comments
 (0)