How to use the spyOnPromise function from aws-sdk
Find comprehensive JavaScript aws-sdk.spyOnPromise code examples handpicked from public code repositorys.
84 85 86 87 88 89 90 91 92 93
await getThing(); expect(get).toHaveBeenCalledWith({ Bucket: 'my', Key: 'thing' }); }); it('can mock .promise() directly', async () => { const get = AWS.spyOnPromise('S3', 'getObject', { Body: 'foo' }); const result = await getThing(); expect(result).toStrictEqual({ Body: 'foo' }); expect(get).toHaveBeenCalledWith({ Bucket: 'my', Key: 'thing' }); });
3
19
79
+ 7 other calls in file
GitHub: mapbox/aws-sdk-jest
66 67 68 69 70 71 72 73 74 75
expect(() => AWS.spyOn('S3', 'FlyingSpaghettiMonster')).toThrow(); }); it('can mock .promise()', async () => { const response = { Body: 'foo' }; const get = AWS.spyOnPromise('S3', 'getObject', response); const result = await underTest(); expect(result).toEqual(response); expect(get).toHaveBeenCalledWith({ Bucket: 'my', Key: 'thing' });
3
19
79
+ 31 other calls in file
24 25 26 27 28 29 30 31 32 33
const listFiles = AWS.spyOnEachPage('S3', 'listObjectsV2', [ { Contents: [{ Key: 'test/path/1.txt' }] }, { Contents: [{ Key: 'text/path/2.txt' }] }, ]) const deleteObjectsResponse = AWS.spyOnPromise('S3', 'deleteObjects', true) const deleteFiles = new Delete({ ...baseParameters, digitalEnableSemver: false,
2
10
3
+ 11 other calls in file
aws-sdk.S3 is the most popular function in aws-sdk (7245 examples)