Created
September 6, 2013 01:10
angular karma unit test
This file contains hidden or 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
| // | |
| // 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); | |
| }) | |
| }); |
This file contains hidden or 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
| 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