Skip to content

Instantly share code, notes, and snippets.

@KamilLelonek
Last active August 29, 2015 14:09
Show Gist options
  • Save KamilLelonek/e4f504c29c8763ddb4f7 to your computer and use it in GitHub Desktop.
Save KamilLelonek/e4f504c29c8763ddb4f7 to your computer and use it in GitHub Desktop.
Test suite for AssetsPartialsLoader extension
describe 'ExtensionsModule', ->
beforeEach module 'StudentHunter.Constants'
beforeEach module 'StudentHunter.SecurityModule'
beforeEach module 'StudentHunter.ExtensionsModule'
describe "AssetsPartialsLoader load", ->
beforeEach module ($provide) ->
$provide.decorator '$compile', ($delegate) ->
return jasmine.createSpy $delegate
beforeEach inject (@$compile, @AssetsPartialsLoader, $injector, @SecurityConstants) ->
@$httpBackend = $injector.get '$httpBackend'
@assetsPartialsHost = "#{@SecurityConstants.assetsHost}/templates/partials.html"
@fakeTemplate = '<div></div>'
it 'should call assets partials API when assetsPartialsLoaded flag is falsy', ->
@$httpBackend.expectGET(@assetsPartialsHost).respond @fakeTemplate
@AssetsPartialsLoader.load()
@$httpBackend.flush()
it 'should compile loaded templates', ->
@$httpBackend.whenGET(@assetsPartialsHost).respond @fakeTemplate
@AssetsPartialsLoader.load()
@$httpBackend.flush()
expect(@$compile).toHaveBeenCalledWith @fakeTemplate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment