Skip to content

Instantly share code, notes, and snippets.

@ahmednuaman
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmednuaman/24917867bd5a3cb17395 to your computer and use it in GitHub Desktop.
Save ahmednuaman/24917867bd5a3cb17395 to your computer and use it in GitHub Desktop.
Angular directive test @ scope
define [
'config'
'directive/radian-directive'
], (cfg, RD) ->
RD 'yolo', [
'$rootScope'
], ($rootScope) ->
restrict: 'A'
replace: true
scope:
item: '@'
# and the test...
define [
'config'
'angular'
'directive/yolo-directive'
], (cfg, A) ->
describe 'Yolo directive', () ->
$scope = null
createDirective = null
el = A.element '<div data-yolo data-item="yolo items"></div>'
beforeEach module cfg.ngApp
beforeEach inject ($injector) ->
$compile = $injector.get '$compile'
$rootScope = $injector.get '$rootScope'
$compiled = $compile el
$scope = $rootScope.$new()
createDirective = () ->
directive = $compiled $scope
$scope.$digest()
directive
it 'should load', () ->
directive = createDirective()
$isolatedScope = directive.isolateScope()
expect($isolatedScope.item).toBe 'yolo items'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment