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' });
});
fork icon3
star icon19
watch icon79

+ 7 other calls in file

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' });
fork icon3
star icon19
watch icon79

+ 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,
fork icon2
star icon10
watch icon3

+ 11 other calls in file