Skip to content

Instantly share code, notes, and snippets.

@KamilLelonek
Created November 19, 2014 07:30
Show Gist options
  • Save KamilLelonek/0db2d2a1eabdb5ccdde9 to your computer and use it in GitHub Desktop.
Save KamilLelonek/0db2d2a1eabdb5ccdde9 to your computer and use it in GitHub Desktop.
Testing ExtensionsModule
describe 'ExtensionsModule', ->
beforeEach module 'StudentHunter.Constants'
beforeEach module 'StudentHunter.ExtensionsModule'
beforeEach module 'StudentHunter.SecurityModule'
beforeEach module 'ui.router'
describe '$templateCache decorator', ->
beforeEach module ($provide) ->
$provide.decorator '$compile', ($delegate) ->
return jasmine.createSpy $delegate
@template = '<div></div>'
it 'puts templates into cache', inject ($templateCache) ->
$templateCache.put('cacheKey', @template)
expect($templateCache.get('cacheKey')).toEqual @template
it 'calls assets partials and compile response if cache key not found', inject ($injector, $templateCache, SecurityConstants) ->
$httpBackend = $injector.get '$httpBackend'
$compile = $injector.get '$compile'
$httpBackend.whenGET("#{SecurityConstants.assetsHost}/templates/partials.html").respond @template
$templateCache.get 'notExistingCacheKey'
$httpBackend.flush()
expect($compile).toHaveBeenCalledWith @template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment