Last active
December 16, 2015 17:49
-
-
Save newtriks/5472834 to your computer and use it in GitHub Desktop.
Jasmine test for blog post http://www.newtriks.com/2013/04/26/how-to-test-an-angularjs-directive/
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
'use strict'; | |
describe('Directive: albums', function() { | |
beforeEach(module('directiveExampleApp')); | |
var element, scope; | |
beforeEach(module('views/templates/albums.html')); | |
beforeEach(inject(function($rootScope, $compile) { | |
element = angular.element('<div class="well span6">' + | |
'<h3>Busdriver Albums:</h3>' + | |
'<albums ng-repeat="album in albums" title="{{album.title}}">' + | |
'</albums></div>'); | |
scope = $rootScope; | |
scope.albums = [{ | |
'title': 'Memoirs of the Elephant Man' | |
}, { | |
'title': 'Temporary Forever' | |
}, { | |
'title': 'Cosmic Cleavage' | |
}, { | |
'title': 'Fear of a Black Tangent' | |
}, { | |
'title': 'RoadKillOvercoat' | |
}, { | |
'title': 'Jhelli Beam' | |
}, { | |
'title': 'Beaus$Eros' | |
}]; | |
$compile(element)(scope); | |
scope.$digest(); | |
})); | |
it("should have the correct amount of albums in the list", function() { | |
var list = element.find('li'); | |
expect(list.length).toBe(7); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment