This repository has been archived by the owner on Aug 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Emulate Apex Calls
Yuriy Sannikov edited this page Jul 23, 2017
·
1 revision
mocha-aura can mock success and failure apex calls. Your callback will be invoked synchronously during $A.enqueueAction call.
it('should call checkSelection', function() {
//Fake result from APEX code
const attendeeObj = {
id: 123,
name: 'test'
}
// Create an instance with success response and payload
const result = apexSuccessResult(attendeeObj);
// Create Apex call object
const declineRSVP = apexCallFactory(result);
// Specify Apex call object among other variables during component creation
const component = componentFactory({
attendeeObj: {id: 456},
declineRSVP
});
const cb = sinon.spy();
helper.declineAttendeeRSVP(component, cb);
expect(declineRSVP.getParams()).to.eql({attendeeId: 456});
expect(helper.checkSelection).to.have.been.calledWith(component);
expect(cb).to.have.been.calledWith(component);
// Check that attendeeObject has data from Apex call
expect(component.get('v.attendeeObj')).to.equal(attendeeObj);
});