Created
October 8, 2014 12:26
-
-
Save lgiraudel/ea937806117973c15734 to your computer and use it in GitHub Desktop.
AngularJS - Test simple 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
<!DOCTYPE html> | |
<!-- // source http://jsbin.com/gazax/1 --> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jasmine/2.0.0/jasmine.js"></script> | |
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/42401/jasmine-html_1.js"></script> | |
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/42401/boot.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-mocks.js"></script> | |
<link type="text/css" rel="stylesheet" href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/42401/jasmine_1.css"></link> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var app = angular.module('myApp', []); | |
app.directive('ehSimple', function() { | |
return function(scope, element) { | |
element.addClass('plain'); | |
}; | |
}); | |
describe('Directive tests', function() { | |
var $scope; | |
var element; | |
beforeEach(module('myApp')); | |
beforeEach(inject(function($compile, $rootScope) { | |
$scope = $rootScope; | |
element = angular.element("<div eh-simple></div>"); | |
$compile(element)($rootScope); | |
})); | |
it('should add a class "plain"', function() { | |
expect(element.hasClass("plain")).toBe(true); | |
}); | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var app = angular.module('myApp', []); | |
app.directive('ehSimple', function() { | |
return function(scope, element) { | |
element.addClass('plain'); | |
}; | |
}); | |
describe('Directive tests', function() { | |
var $scope; | |
var element; | |
beforeEach(module('myApp')); | |
beforeEach(inject(function($compile, $rootScope) { | |
$scope = $rootScope; | |
element = angular.element("<div eh-simple></div>"); | |
$compile(element)($rootScope); | |
})); | |
it('should add a class "plain"', function() { | |
expect(element.hasClass("plain")).toBe(true); | |
}); | |
});</script></body> | |
</html> |
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
var app = angular.module('myApp', []); | |
app.directive('ehSimple', function() { | |
return function(scope, element) { | |
element.addClass('plain'); | |
}; | |
}); | |
describe('Directive tests', function() { | |
var $scope; | |
var element; | |
beforeEach(module('myApp')); | |
beforeEach(inject(function($compile, $rootScope) { | |
$scope = $rootScope; | |
element = angular.element("<div eh-simple></div>"); | |
$compile(element)($rootScope); | |
})); | |
it('should add a class "plain"', function() { | |
expect(element.hasClass("plain")).toBe(true); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment