This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* closes #122 Added Schedule Support * Added Test for Schedule action * Updated Test case * Missing semicolon * Corrected Tests and validated * Increment Version * Bumped version to 2.2.4 Changed version as per PR reviewer request
- Loading branch information
1 parent
9675827
commit df1e4e9
Showing
4 changed files
with
162 additions
and
3 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
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,103 @@ | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var proxyquire = require('proxyquire'); | ||
var sinon = require('sinon'); | ||
|
||
describe('SOAP Action - schedule', function() { | ||
var FuelSoap; | ||
var soapRequestSpy; | ||
var parsedOptions = { parsedOptions: true }; | ||
var simpleVerifyTestCases = [ | ||
{ property: 'action', expected: 'Schedule' } | ||
, { property: 'key', expected: 'ScheduleResponseMsg' } | ||
, { property: 'retry', expected: true } | ||
, { property: 'reqOptions', expected: parsedOptions } | ||
]; | ||
|
||
var exampleSchedule = { | ||
Recurrence: { | ||
$: {'xsi:type': 'MinutelyRecurrence'}, | ||
MinutelyRecurrencePatternType: 'Interval', | ||
MinuteInterval: '10' | ||
}, | ||
RecurrenceType: 'Minutely', | ||
RecurrenceRangeType: 'EndAfter', | ||
StartDateTime: '2019-04-10T10:10:00.046+01:00', | ||
Occurrences: '999999' | ||
}; | ||
var exampleInteractions =[ | ||
{ | ||
Interaction: { | ||
ObjectID: '1234' | ||
} | ||
} | ||
]; | ||
|
||
beforeEach(function() { | ||
FuelSoap = proxyquire('../../lib/fuel-soap', { | ||
'./helpers': { | ||
parseReqOptions: function() { return parsedOptions; } | ||
} | ||
}); | ||
soapRequestSpy = sinon.stub(FuelSoap.prototype, 'soapRequest'); | ||
}); | ||
|
||
afterEach(function() { | ||
FuelSoap.prototype.soapRequest.restore(); | ||
}); | ||
simpleVerifyTestCases.forEach(function(testCase) { | ||
it('should call soapRequest with correct ' + testCase.property, function() { | ||
// Act | ||
FuelSoap.prototype.schedule( | ||
'Test', | ||
exampleSchedule, | ||
exampleInteractions, | ||
'start', | ||
{ options: true }, | ||
function() {}); | ||
// Assert | ||
assert.equal(soapRequestSpy.args[0][0][testCase.property], testCase.expected); | ||
}); | ||
}); | ||
it('should pass correct body to soapRequest', function() { | ||
|
||
// Act | ||
FuelSoap.prototype.schedule('Test', exampleSchedule, exampleInteractions,'start',{ options: true } , function() {}); | ||
// Assert | ||
var actualObj = soapRequestSpy.args[0][0].req; | ||
assert.equal(actualObj.ScheduleRequestMsg.Schedule, exampleSchedule); | ||
assert.equal(actualObj.ScheduleRequestMsg.Interactions, exampleInteractions); | ||
assert.ok(!actualObj.ScheduleRequestMsg.Options.QueryAllAccounts); | ||
}); | ||
|
||
it('should pass callback to soapRequest when options', function() { | ||
// Arrange | ||
var sampleCallback = sinon.spy(); | ||
|
||
// Act | ||
FuelSoap.prototype.schedule('Test', exampleSchedule, exampleInteractions,'start', { options: true }, sampleCallback); | ||
|
||
// Assert | ||
assert.ok(soapRequestSpy.calledWith(sinon.match.object, sampleCallback)); | ||
}); | ||
|
||
it('should add QueryAllAccounts to body when option passed', function() { | ||
// Arrange | ||
var sampleOptions = { queryAllAccounts: true }; | ||
|
||
// Act | ||
FuelSoap.prototype.schedule('Test', exampleSchedule, exampleInteractions,'start',sampleOptions , function() {}); | ||
|
||
// Assert | ||
var actualObj = soapRequestSpy.args[0][0].req; | ||
assert.ok(actualObj.ScheduleRequestMsg.Options.QueryAllAccounts); | ||
}); | ||
}); |