@botpress/client 0.25.1 → 0.26.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/client",
3
- "version": "0.25.1",
3
+ "version": "0.26.1",
4
4
  "description": "Botpress Client",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -16,30 +16,46 @@ describe('uploadFile', () => {
16
16
  token: 'bp_pat_abcdefghijklmnopqrstuvwxyz0123456789',
17
17
  })
18
18
 
19
- it('works with a buffer', async () => {
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: Buffer.from('aaa'),
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 content = await fetch(response.file.url).then((res) => res.text())
29
- expect(content).toBe('aaa')
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 plain text', async () => {
33
- const response = await client.uploadFile({
34
- key: 'test.txt',
35
- content: 'aaa',
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
- expect(response.file.key).toBe('test.txt')
39
- expect(response.file.url, 'File URL should have been returned').toBeTruthy()
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
- const content = await fetch(response.file.url).then((res) => res.text())
42
- expect(content).toBe('aaa')
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 () => {