Skip to content

Instantly share code, notes, and snippets.

@felixzapata
Created September 11, 2013 09:13
Show Gist options
  • Save felixzapata/6521203 to your computer and use it in GitHub Desktop.
Save felixzapata/6521203 to your computer and use it in GitHub Desktop.
Common skeleton unit test for a directive
describe('myDir directive', function () {
var element, scope;
beforeEach(module('myDirModule'));
beforeEach(inject(function ($compile, $rootScope) {
var linkingFn = $compile('<my-dir></my-dir>');
scope = $rootScope;
element = linkingFn(scope);
}));
it('has some properties', function() {
expect(element.someMethod()).toBe(XXX);
});
it('does something to the scope', function() {
expect(scope.someField).toBe(XXX);
});
....
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment