From 3fadc6f82a25fe9ea23a71814afb401f5582532a Mon Sep 17 00:00:00 2001 From: Clay Anderson Date: Tue, 14 Oct 2014 08:34:01 -0600 Subject: [PATCH] Added model (scope) and tests --- app/view1/view1.html | 1 + app/view1/view1.js | 4 ++-- app/view1/view1_test.js | 25 ++++++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/view1/view1.html b/app/view1/view1.html index 89459a65ca..6fece371e2 100644 --- a/app/view1/view1.html +++ b/app/view1/view1.html @@ -1 +1,2 @@

This is the partial for view 1.

+

Message: {{message}}

diff --git a/app/view1/view1.js b/app/view1/view1.js index 4ce0b4f118..f221a2f29a 100644 --- a/app/view1/view1.js +++ b/app/view1/view1.js @@ -9,6 +9,6 @@ angular.module('myApp.view1', ['ngRoute']) }); }]) -.controller('View1Ctrl', [function() { - +.controller('View1Ctrl', ['$scope', function($scope) { + $scope.message = 'angular fun'; }]); \ No newline at end of file diff --git a/app/view1/view1_test.js b/app/view1/view1_test.js index 14ba79b48f..6bbffedf7d 100644 --- a/app/view1/view1_test.js +++ b/app/view1/view1_test.js @@ -5,12 +5,27 @@ describe('myApp.view1 module', function() { beforeEach(module('myApp.view1')); describe('view1 controller', function(){ - - it('should ....', inject(function($controller) { - //spec body - var view1Ctrl = $controller('View1Ctrl'); - expect(view1Ctrl).toBeDefined(); + var scope; + var controller; + + beforeEach(inject(function ($rootScope, $controller) { + scope = $rootScope.$new(); + controller = $controller('View1Ctrl', { + '$scope': scope + }); })); + + it('should be created', function() { + expect(controller).toBeDefined(); + }); + + it('should populate message', function() { + expect(scope.message).toBeDefined(); + }); + + it('should populate message exactly', function() { + expect(scope.message).toEqual('angular fun'); + }); }); }); \ No newline at end of file