Skip to content

Instantly share code, notes, and snippets.

@lgiraudel
Last active August 29, 2015 14:07
Show Gist options
  • Save lgiraudel/d3c5cf6fcae8ebc38165 to your computer and use it in GitHub Desktop.
Save lgiraudel/d3c5cf6fcae8ebc38165 to your computer and use it in GitHub Desktop.
AngularJS - Test a simple expression
<!DOCTYPE html>
<!-- // source http://jsbin.com/zirivocogeji/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">
describe('Hello world', function() {
var element;
var $scope;
beforeEach(inject(function($compile, $rootScope) {
$scope = $rootScope,
element = angular.element('<div>{{ 2 + 2 }}</div>');
element = $compile(element)($rootScope);
}));
it('should equal 4', function() {
$scope.$digest();
expect(element.html()).toBe('4');
});
});
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"><\/script>
<script src="//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>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript">describe('Hello world', function() {
var element;
var $scope;
beforeEach(inject(function($compile, $rootScope) {
$scope = $rootScope,
element = angular.element('<div>{{ 2 + 2 }}</div>');
element = $compile(element)($rootScope);
}));
it('should equal 4', function() {
$scope.$digest();
expect(element.html()).toBe('4');
});
});</script></body>
</html>
describe('Hello world', function() {
var element;
var $scope;
beforeEach(inject(function($compile, $rootScope) {
$scope = $rootScope,
element = angular.element('<div>{{ 2 + 2 }}</div>');
element = $compile(element)($rootScope);
}));
it('should equal 4', function() {
$scope.$digest();
expect(element.html()).toBe('4');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment