From 76584e17fe977e9fe79d7721e7733d8fffbafc90 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 30 Aug 2015 01:20:30 +0200 Subject: [PATCH] showcase: cars-error-modal.controller.spec --- .../app/cars/cars-error-modal.controller.spec.js | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 angularjs/showcase/src/showcase/app/cars/cars-error-modal.controller.spec.js 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'); + }); + + }); + +}); -- 2.1.4