From: Gustavo Martin Morcuende Date: Sat, 29 Aug 2015 23:20:30 +0000 (+0200) Subject: showcase: cars-error-modal.controller.spec X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=76584e17fe977e9fe79d7721e7733d8fffbafc90;p=JavaScriptForFun showcase: cars-error-modal.controller.spec --- diff --git a/angularjs/showcase/src/showcase/app/cars/cars-error-modal.controller.spec.js b/angularjs/showcase/src/showcase/app/cars/cars-error-modal.controller.spec.js new file mode 100644 index 0000000..f85e9f4 --- /dev/null +++ b/angularjs/showcase/src/showcase/app/cars/cars-error-modal.controller.spec.js @@ -0,0 +1,39 @@ +describe('app.cars', function() { + 'use strict'; + + var cars = ['car1', 'car2', 'car3']; + var $modalInstance = { + close: jasmine.createSpy('modalInstance.close'), + dismiss: jasmine.createSpy('modalInstance.dismiss') + }; + var CarsErrorModal; + + beforeEach(function() { + module('app.cars'); + + inject(function($controller) { + CarsErrorModal = $controller('CarsErrorModal', { + $modalInstance: $modalInstance, + cars: cars + }); + }); + + }); + + describe('CarsErrorModal controller', function () { + + it('should invoke $modalInstance.close', function () { + CarsErrorModal.ok(); + + expect($modalInstance.close).toHaveBeenCalledWith('car1'); + }); + + it('should invoke $modalInstance.dismiss', function () { + CarsErrorModal.cancel(); + + expect($modalInstance.dismiss).toHaveBeenCalledWith('cancel'); + }); + + }); + +});