Skip to content

Commit aea1c14

Browse files
committed
chore: simplify tests
1 parent b30eaee commit aea1c14

File tree

1 file changed

+4
-35
lines changed

1 file changed

+4
-35
lines changed

src/main.test.ts

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,43 +57,12 @@ describe('get', () => {
5757
fetcher,
5858
siteID,
5959
})
60-
const val = await blobs.get(key)
6160

62-
expect(val).toBe(value)
63-
})
64-
65-
test('Returns a stream', async () => {
66-
const fetcher = async (...args: Parameters<typeof globalThis.fetch>) => {
67-
const [url, options] = args
68-
const headers = options?.headers as Record<string, string>
69-
70-
expect(options?.method).toBe('get')
71-
72-
if (url === `https://api.netlify.com/api/v1/sites/${siteID}/blobs/${key}?context=production`) {
73-
const data = JSON.stringify({ url: signedURL })
74-
75-
expect(headers.authorization).toBe(`Bearer ${apiToken}`)
76-
77-
return new Response(data)
78-
}
79-
80-
if (url === signedURL) {
81-
return new Response(value)
82-
}
83-
84-
throw new Error(`Unexpected fetch call: ${url}`)
85-
}
86-
87-
const blobs = new Blobs({
88-
authentication: {
89-
token: apiToken,
90-
},
91-
fetcher,
92-
siteID,
93-
})
94-
const val = await blobs.get(key, { type: 'stream' })
61+
const string = await blobs.get(key)
62+
expect(string).toBe(value)
9563

96-
expect(await streamToString(val as unknown as NodeJS.ReadableStream)).toBe(value)
64+
const stream = await blobs.get(key, { type: 'stream' })
65+
expect(await streamToString(stream as unknown as NodeJS.ReadableStream)).toBe(value)
9766
})
9867

9968
test('Returns `null` when the pre-signed URL returns a 404', async () => {

0 commit comments

Comments
 (0)