I'm fairly new to angular/karma testing.
I have a function within my directive the generates a modal upon the selection of an appropriate date selection withn another modal (I.e. a user clicks a button, a modal appears prompting the user to select a certain date; when the user submits a date - a subsequent 'Response' Modal is shown. I have laid out pseudo-code below for simplicity sake:
specifyDate = function(object) {
var modal = dateSelectionModalService.showDateSelectionModal()
modal.result.then(function (date) {
dateSelectionModalService.showResponseModal();
}
The code works and I'm currently trying to establish a karma test based on the response modal being generated when a date is submitted.
My thinking for that particular test so far has been:
it('should show the response modal when date selected', function() {
var defferedModalResponse = $q.defer(),
modalResult = {result: deferedModalResponse.promise};
spyOn(dateSelectionModalService, 'showResponseModal')
(dateSelectionModalService, 'showDateSelectionModal').and.returnValue(modalResult);
expect(datePickerModalService.showChangedEffectiveDateModal).toHaveBeenCalled();
});
Am I thinking along the right way? Or is there something completely different as to how I should look at this?
Aucun commentaire:
Enregistrer un commentaire