@botpress/client 0.25.1 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-generate.log +1 -1
- package/dist/bundle.cjs +7 -7
- package/dist/bundle.cjs.map +3 -3
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +3 -3
- package/package.json +1 -1
- package/tests/manual/file-upload.test.ts +29 -13
package/package.json
CHANGED
|
@@ -16,30 +16,46 @@ describe('uploadFile', () => {
|
|
|
16
16
|
token: 'bp_pat_abcdefghijklmnopqrstuvwxyz0123456789',
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const testContent = 'aaa'
|
|
20
|
+
|
|
21
|
+
async function test(content: Buffer | ArrayBuffer | Uint8Array | Blob | string) {
|
|
20
22
|
const response = await client.uploadFile({
|
|
21
23
|
key: 'test.txt',
|
|
22
|
-
content:
|
|
24
|
+
content: content as any,
|
|
23
25
|
})
|
|
24
26
|
|
|
25
27
|
expect(response.file.key).toBe('test.txt')
|
|
26
28
|
expect(response.file.url, 'File URL should have been returned').toBeTruthy()
|
|
27
29
|
|
|
28
|
-
const
|
|
29
|
-
expect(
|
|
30
|
+
const fetchedContent = await fetch(response.file.url).then((res) => res.text())
|
|
31
|
+
expect(fetchedContent).toBe(testContent)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
it('works with a string', async () => {
|
|
35
|
+
await test(testContent)
|
|
30
36
|
})
|
|
31
37
|
|
|
32
|
-
it('works with
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
it('works with a Uint8Array', async () => {
|
|
39
|
+
const encoder = new TextEncoder()
|
|
40
|
+
const uint8Array = encoder.encode(testContent)
|
|
41
|
+
await test(uint8Array)
|
|
42
|
+
})
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
it('works with a Buffer', async () => {
|
|
45
|
+
const buffer = Buffer.from(testContent)
|
|
46
|
+
await test(buffer)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('works with an ArrayBuffer', async () => {
|
|
50
|
+
const encoder = new TextEncoder()
|
|
51
|
+
const uint8Array = encoder.encode(testContent)
|
|
52
|
+
const arrayBuffer = uint8Array.buffer
|
|
53
|
+
await test(arrayBuffer)
|
|
54
|
+
})
|
|
40
55
|
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
it('works with a Blob', async () => {
|
|
57
|
+
const blob = new Blob([testContent], { type: 'text/plain' })
|
|
58
|
+
await test(blob)
|
|
43
59
|
})
|
|
44
60
|
|
|
45
61
|
it('works with a URL', async () => {
|