Skip to content

Instantly share code, notes, and snippets.

@yury-sannikov
Last active September 22, 2017 19:54
Show Gist options
  • Save yury-sannikov/c958cc0502afff220b8da0964095f73d to your computer and use it in GitHub Desktop.
Save yury-sannikov/c958cc0502afff220b8da0964095f73d to your computer and use it in GitHub Desktop.
@testMethod('checkSeatings should return rejected promise on error')
@inject(null, 'error')
@testMethod('checkSeatings should return rejected promise if seats and capacity doesnt match')
@inject({sections: [{seats: 1}], ticketQuantityAvailable: 5}, null)
@inject({sections: [{seats: 1}, {seats: 2}], ticketQuantityAvailable: 5}, null)
@testMethod('checkSeatings should return resolved promise')
@inject({sections: [{seats: 1}, {seats: 2}, {seats: 2}], ticketQuantityAvailable: 5}, null)
checkSeatings(result, error, done) {
const getSections = apexCallFactory(error ? apexErrorResult(error) : apexSuccessResult(result));
const component = componentFactory({
getSections, eventId: 10,
findMap: {toastMessages: 'Framework:Toast'}
});
helper.checkSeatings(component).then(() => {
expect(component.find('toastMessages').showMessage).not.to.have.been.called;
done();
}).catch((msg) => {
if (error) {
expect(component.find('toastMessages').showMessage).to.have.been.called;
} else {
expect(component.find('toastMessages').showMessage).not.to.have.been.called;
expect(msg).to.equal($A.get('$Label.c.Event_Builder_Seating_Ticket_Capacity_Doesnt_Match'));
}
done();
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment