Skip to content

Instantly share code, notes, and snippets.

@ariesjia
Created September 6, 2013 01:10
angular karma unit test
//
// test/unit/directives/directivesSpec.js
//
describe("Unit: Testing Directives", function() {
var $compile, $rootScope;
beforeEach(angular.mock.module('App'));
beforeEach(inject(
['$compile','$rootScope', function($c, $r) {
$compile = $c;
$rootScope = $r;
}]
));
it("should display the welcome text properly", function() {
var element = $compile('<div data-app-welcome>User</div>')($rootScope);
expect(element.html()).to.match(/Welcome/i);
})
});
function compile(template) {
var element = $compile(template)(scope);
cope.$apply();
$timeout.flush();
return element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment