-
Notifications
You must be signed in to change notification settings - Fork 15
/
listBuckets.test.js
38 lines (30 loc) · 935 Bytes
/
listBuckets.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {
describe,
it,
expect,
jest
} from '@jest/globals'
import { S3 } from './../../src/factory.js'
import { main } from './../../src/index.js'
describe('Unit Tests', () => {
it('it should return an array with a S3 Bucket', async () => {
const myBuckets = [
{
Name: "dvds-piratas001",
CreationDate: '2024-03-20T20:32:13.000Z'
},
{
Name: "foto-de-familia001",
CreationDate: '2024-03-20T20:32:13.000Z'
},
]
jest.spyOn(S3, 'listBuckets').mockResolvedValue({
Buckets: myBuckets
})
const response = await main()
const { allBuckets: { Buckets } } = JSON.parse(response.body)
expect(S3.listBuckets).toBeCalledTimes(1)
expect(Buckets).toStrictEqual(myBuckets)
expect(response.statusCode).toStrictEqual(200)
})
})