Skip to content

Instantly share code, notes, and snippets.

@philipjfulcher
Created April 17, 2020 20:12
Show Gist options
  • Save philipjfulcher/099988e82cd3d976d3700756d96b173a to your computer and use it in GitHub Desktop.
Save philipjfulcher/099988e82cd3d976d3700756d96b173a to your computer and use it in GitHub Desktop.
Example AngularJS unit test
import articleModule from './index';
beforeEach(() => {
// Create the module where our functionality can attach to
angular.mock.module('ui.router');
angular.mock.module(articleModule.name);
});
let component;
beforeEach(angular.mock.inject(($rootScope, $componentController) => {
let User = {
current: false
};
component = $componentController('comment', { User });
}));
describe('comment component', () => {
it('should be defined', () => {
expect(component).toBeDefined();
});
it('should default canModify to false', () => {
expect(component.canModify).toEqual(false);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment