-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from emartech/add-contact-field-delete
feat(field): add contact field DELETE CDP-1737
- Loading branch information
Showing
7 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
var _ = require('lodash'); | ||
|
||
module.exports = { | ||
shouldDeleteResourceOnEndpoint: function(expectedUrl, expectedData) { | ||
var apiEndpoint; | ||
var request; | ||
|
||
|
||
expectedData = expectedData || this._requestRespondWith; | ||
|
||
describe('towards ' + expectedUrl + ' endpoint', function() { | ||
|
||
var self = this; | ||
|
||
beforeEach(function() { | ||
request = self._getRequestStub(); | ||
apiEndpoint = self.ApiEndpoint.create(request, { customerId: 123 }); | ||
}); | ||
|
||
it('should properly call a DELETE request', async function() { | ||
await apiEndpoint[self.method](self.payload, self.options); | ||
expect(request.delete).to.have.been.callCount(1); | ||
expect(request.delete).to.have.been.calledWith(123, expectedUrl, {}); | ||
}); | ||
|
||
|
||
it('should return the result', async function() { | ||
var result = await apiEndpoint[self.method](self.payload, self.options); | ||
expect(request.delete).to.have.been.callCount(1); | ||
expect(result).to.eql(expectedData); | ||
}); | ||
|
||
|
||
it('should pass the options to the suite request', async function() { | ||
var options = _.merge({ customerId: 999, environment: 'otherEnv' }, self.options); | ||
await apiEndpoint[self.method](self.payload, options); | ||
expect(request.delete).to.have.been.callCount(1); | ||
expect(request.delete).to.have.been.calledWithExactly(sinon.match.any, sinon.match.any, options); | ||
}); | ||
|
||
|
||
it('should override customerId from the options', async function() { | ||
await apiEndpoint[self.method](self.payload, { customerId: 999 }); | ||
expect(request.delete).to.have.been.callCount(1); | ||
expect(request.delete).to.have.been.calledWithExactly(999, sinon.match.any, { customerId: 999 }); | ||
}); | ||
}.bind(this)); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters