Created
July 23, 2014 11:13
-
-
Save karlwestin/7506ec6c234ef32679c4 to your computer and use it in GitHub Desktop.
angular testing pt 2
This file contains 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
/* | |
So it turns out angular writers are just half-familiar with jasmine etc practices | |
angular-mocks actually supports doing this: | |
*/ | |
// Load the myApp module, which contains the directive | |
beforeEach(module('myApp')); | |
// Store references to $rootScope and $compile | |
// so they are available to all tests in this describe block | |
beforeEach(inject(function(_$compile_, _$rootScope_){ | |
// The injector unwraps the underscores (_) from around the parameter names when matching | |
this.$compile = _$compile_; | |
this.$rootScope = _$rootScope_; | |
})); | |
it("should test compiler", function() { | |
// Compile service now available on 'this' scope (one scope per test) | |
// just like we wanna do with jasmine testing :) | |
this.$compile | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment