Skip to content

Instantly share code, notes, and snippets.

@xphong
Created July 15, 2015 14:28
Show Gist options
  • Save xphong/ba7092a550ce17bc22c8 to your computer and use it in GitHub Desktop.
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
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