Created
May 23, 2014 14:14
-
-
Save miguelsaddress/071b3405ba3bf7ec7c22 to your computer and use it in GitHub Desktop.
Testing a directive example
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
var scope, compiledTemplate, UserService, deferred; | |
//We must load the app module | |
//and VERY IMPORTANT, the template the directive uses via templateUrl | |
var TEMPLATE_URL = 'app/account/public/views/signupForm.html'; //proper path to the template | |
var TEMPLATE_KEY = '/app/account/public/views/signupForm.html'; //as loaded in the directive, used as Key in the tempalteCache | |
beforeEach( module( 'tybaNg', TEMPLATE_URL ) ); | |
beforeEach(inject(function($injector) { | |
var $compile = $injector.get('$compile'); | |
var $rootScope = $injector.get('$rootScope'); | |
var $templateCache = $injector.get('$templateCache'); | |
var $q = $injector.get('$q'); | |
UserService = $injector.get('user'); | |
//assign the template to the expected url called by the directive and put it in the cache | |
var template = $templateCache.get(TEMPLATE_URL); | |
$templateCache.put(TEMPLATE_KEY,template); | |
var element = angular.element('<div signup-form onsignup="onSignupMock()"></div>'); | |
compiledTemplate = $compile(element)($rootScope); | |
$rootScope.$digest(); | |
scope = element.isolateScope(); | |
deferred = $q.defer(); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment