|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import Browserbase from '@browserbasehq/sdk'; |
| 4 | +import { Response } from 'node-fetch'; |
| 5 | + |
| 6 | +const client = new Browserbase({ |
| 7 | + apiKey: 'My API Key', |
| 8 | + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', |
| 9 | +}); |
| 10 | + |
| 11 | +describe('resource replays', () => { |
| 12 | + test('retrieve', async () => { |
| 13 | + const responsePromise = client.sessions.replays.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); |
| 14 | + const rawResponse = await responsePromise.asResponse(); |
| 15 | + expect(rawResponse).toBeInstanceOf(Response); |
| 16 | + const response = await responsePromise; |
| 17 | + expect(response).not.toBeInstanceOf(Response); |
| 18 | + const dataAndResponse = await responsePromise.withResponse(); |
| 19 | + expect(dataAndResponse.data).toBe(response); |
| 20 | + expect(dataAndResponse.response).toBe(rawResponse); |
| 21 | + }); |
| 22 | + |
| 23 | + test('retrieve: request options instead of params are passed correctly', async () => { |
| 24 | + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error |
| 25 | + await expect( |
| 26 | + client.sessions.replays.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { |
| 27 | + path: '/_stainless_unknown_path', |
| 28 | + }), |
| 29 | + ).rejects.toThrow(Browserbase.NotFoundError); |
| 30 | + }); |
| 31 | + |
| 32 | + test('retrievePage: request options instead of params are passed correctly', async () => { |
| 33 | + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error |
| 34 | + await expect( |
| 35 | + client.sessions.replays.retrievePage('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', '090', { |
| 36 | + path: '/_stainless_unknown_path', |
| 37 | + }), |
| 38 | + ).rejects.toThrow(Browserbase.NotFoundError); |
| 39 | + }); |
| 40 | +}); |
0 commit comments