Skip to content

Commit

Permalink
Merge 79e33c7 into 75b7ee3
Browse files Browse the repository at this point in the history
  • Loading branch information
Nataniel López committed Apr 27, 2020
2 parents 75b7ee3 + 79e33c7 commit 1cc3277
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- `deleteObjects` method

## [1.2.1] - 2019-12-16
### Fixed
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -20,6 +20,7 @@ The possible methods are:
* `putObject`
* `headObject`
* `deleteObject`
* `deleteObjects`
* `listObjects`
* `listBuckets`
* `createBucket`
Expand Down
1 change: 1 addition & 0 deletions lib/s3.js
Expand Up @@ -6,6 +6,7 @@ module.exports = {
getObject: params => s3Wrapper.getObject(params).promise(),
putObject: params => s3Wrapper.putObject(params).promise(),
deleteObject: params => s3Wrapper.deleteObject(params).promise(),
deleteObjects: params => s3Wrapper.deleteObjects(params).promise(),
listObjects: params => s3Wrapper.listObjects(params).promise(),
listBuckets: params => s3Wrapper.listBuckets(params).promise(),
createBucket: params => s3Wrapper.createBucket(params).promise(),
Expand Down
33 changes: 33 additions & 0 deletions tests/s3-test.js
Expand Up @@ -118,6 +118,39 @@ describe('S3', () => {
});
});

context('deleteObjects', () => {

it('Should return a the same response when calling to deleteObjects method', async () => {

sinon.stub(s3Wrapper, 'deleteObjects').returns({ promise: () => Promise.resolve(s3Params) });

const deleteObjectsInstance = await S3.deleteObjects(s3Params);

assert.deepStrictEqual(deleteObjectsInstance, s3Params);
});

it('Should rejects the promise calling to deleteObjects method', async () => {

const message = 'random message error';

sinon.stub(s3Wrapper, 'deleteObjects').returns({ promise: () => Promise.reject(new Error(message)) });

assert.rejects(S3.deleteObjects(s3Params), {
name: 'Error',
message
});
});

it('Should call with the same params to deleteObjects method', async () => {

sinon.stub(s3Wrapper, 'deleteObjects').returns({ promise: () => Promise.resolve(s3Params) });

await S3.deleteObjects(s3Params);

sinon.assert.calledWithExactly(s3Wrapper.deleteObjects, s3Params);
});
});

context('listObjects', () => {

it('Should return a the same response when calling to listObjects method', async () => {
Expand Down

0 comments on commit 1cc3277

Please sign in to comment.