Last active
August 29, 2015 14:02
-
-
Save ahmednuaman/24917867bd5a3cb17395 to your computer and use it in GitHub Desktop.
Angular directive test @ scope
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
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