showcase: cars-error-modal.controller.spec
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sat, 29 Aug 2015 23:20:30 +0000 (01:20 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sat, 29 Aug 2015 23:20:30 +0000 (01:20 +0200)
angularjs/showcase/src/showcase/app/cars/cars-error-modal.controller.spec.js [new file with mode: 0644]

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 (file)
index 0000000..f85e9f4
--- /dev/null
@@ -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');
+    });
+
+  });
+
+});