Created
July 15, 2015 14:28
-
-
Save xphong/ba7092a550ce17bc22c8 to your computer and use it in GitHub Desktop.
Example karma unit test for ngBoilerplate http://joshdmiller.github.io/ng-boilerplate/#/home
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Home Page', function () { | |
var controller; | |
beforeEach(module('app.home')); | |
beforeEach(inject(function ($controller) { | |
controller = $controller; | |
controller = $controller('HomeController', {}); | |
})); | |
it('should set someVar to blue', function() { | |
expect(controller.someVar).toEqual('blue'); | |
}); | |
it('should set someList to one, two, three', function() { | |
expect(controller.someList).toEqual(['one', 'two', 'three']); | |
}); | |
describe('Click Button', function () { | |
it('should show alert message when clicked', function() { | |
spyOn(window, 'alert'); | |
controller.someFunctionUsedByTheHomePage(); | |
expect(window.alert).toHaveBeenCalledWith('Congratulations'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment