Skip to content

Commit

Permalink
Merge pull request #106 from jakemmarsh/fix-directive
Browse files Browse the repository at this point in the history
Fix directive
  • Loading branch information
jakemmarsh committed Nov 7, 2015
2 parents 89e1d70 + 4994907 commit 335001d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/js/directives/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ function ExampleDirective() {
title: '@',
message: '@exampleDirective'
},
link: (scope, element, attrs) => {
link: (scope, element) => {
element.on('click', () => {
alert('Element clicked: ' + scope.message);
window.alert('Element clicked: ' + scope.message);
});
}
};
Expand Down
10 changes: 5 additions & 5 deletions test/unit/directives/example_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ describe('Unit: ExampleDirective', function() {
angular.mock.inject(function($compile, $rootScope) {
scope = $rootScope;
element = angular.element('<div example-directive="{{message}}" title="{{title}}">Sample Directive</div>');
scope.title = "A sample title";
scope.message = "It doesn't hurt.";
scope.title = 'A sample title';
scope.message = 'It doesn\'t hurt.';
$compile(element)(scope);
scope.$digest();
});
});

it('should bind itself to the element', function() {
element.triggerHandler('click');
expect(window.alert).toHaveBeenCalledWith("Element clicked: It doesn't hurt.");
expect(window.alert).toHaveBeenCalledWith('Element clicked: It doesn\'t hurt.');
});

it('should update its bindings', function() {
scope.message = "It hurts a bit.";
scope.message = 'It hurts a bit.';
scope.$digest();
element.triggerHandler('click');
expect(window.alert).toHaveBeenCalledWith("Element clicked: It hurts a bit.");
expect(window.alert).toHaveBeenCalledWith('Element clicked: It hurts a bit.');
});

it('should bind a title property to its template', function() {
Expand Down

0 comments on commit 335001d

Please sign in to comment.