Skip to content

Commit a273a69

Browse files
committed
Initial commit
0 parents  commit a273a69

29 files changed

+4659
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
app/lib/

.jshintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"strict": "global",
3+
"globals": {
4+
"angular": true
5+
}
6+
}

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
sudo: false
3+
node_js:
4+
- '8'

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
AngularJS 1.x testing with Jasmine
2+
3+
$ git clone [email protected]/ashawley/angularjs-jasmine-karma.git -o upstream
4+
5+
$ npm install
6+
added 469 packages in 20.186s
7+
8+
$ npm install -g karma-cli
9+
/usr/local/bin/karma -> /usr/local/lib/node_modules/karma-cli/bin/karma
10+
11+
added 3 packages in 3.408s
12+
13+
$ npm start
14+
15+
> [email protected] start ./angularjs-jasmine-karma
16+
> http-server -a localhost -p 8080 -c-1 ./app
17+
18+
Starting up http-server, serving ./app
19+
Available on:
20+
http://localhost:8080
21+
Hit CTRL-C to stop the server
22+
23+
$ karma start --single-run
24+
INFO [karma]: Karma v0.13.22 server started at http://localhost:9877/
25+
TOTAL: 18 SUCCESS
26+
27+
$ karma start --browsers Chrome
28+
29+
https://docs.angularjs.org/tutorial
30+
https://docs.angularjs.org/guide
31+
http://bguiz.github.io/js-standards/angularjs/naming/

app/app.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
angular.module('myApp', [
4+
'ngRoute',
5+
'ngSanitize',
6+
'mainModule'
7+
]);

app/appConfig.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
angular.module('myApp')
4+
.config(function (mainProvider) {
5+
mainProvider.setGreeting('HELLO, WORLD!');
6+
}
7+
);

app/index.html

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!doctype html>
2+
<html lang="en" ng-app="myApp">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Hello, world!</title>
8+
<meta name="description" content="">
9+
<meta name="viewport" content="width=device-width, initial-scale=1">
10+
11+
<link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.css" />
12+
<!-- <link rel="stylesheet" href="app.css"> -->
13+
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
14+
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
15+
<!--[if lt IE 9]>
16+
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
17+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
18+
<![endif]-->
19+
</head>
20+
<body class="container" ng-controller="mainController">
21+
<main-directive/>
22+
23+
<script src="lib/jquery/dist/jquery.js"></script>
24+
<script src="lib/angular/angular.js"></script>
25+
<script src="lib/angular-route/angular-route.js"></script>
26+
<script src="lib/angular-sanitize/angular-sanitize.js"></script>
27+
<script src="main/mainModule.js"></script>
28+
<script src="main/mainValue.js"></script>
29+
<script src="main/mainService.js"></script>
30+
<script src="main/mainProvider.js"></script>
31+
<script src="main/mainFilter.js"></script>
32+
<script src="main/mainController.js"></script>
33+
<script src="main/mainDirective.js"></script>
34+
<!-- <script src="main/mainConfig.js"></script> -->
35+
<script src="app.js"></script>
36+
<!-- <script src="appConfig.js"></script> -->
37+
<script src="lib/bootstrap/dist/js/bootstrap.js"></script>
38+
</body>
39+
</html>

app/main/mainConfig.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
angular.module('mainModule')
4+
.config(function (mainProvider) {
5+
mainProvider.setGreeting('Hello, world!');
6+
}
7+
);

app/main/mainController.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
angular.module('mainModule').controller('mainController',
4+
function ($scope, mainProvider) {
5+
$scope.greeting = 'Hello, world!'; // mainProvider.greeting();
6+
}
7+
);

app/main/mainDirective.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
angular.module('mainModule')
4+
.directive('mainDirective', function () {
5+
return {
6+
template: '<h1>{{greeting}}</h1>'
7+
// templateUrl: 'main/mainView.html'
8+
};
9+
}
10+
);

app/main/mainFilter.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
angular.module('mainModule')
4+
.filter('mainFilter', function () {
5+
return function(text) {
6+
return text.toUpperCase();
7+
};
8+
}
9+
);

app/main/mainModule.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
angular.module('mainModule', []);

app/main/mainProvider.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
angular.module('mainModule')
4+
.provider('mainProvider', mainProvider);
5+
6+
function mainProvider() {
7+
var greeting;
8+
return {
9+
setGreeting: function(value) {
10+
greeting = value;
11+
},
12+
$get: function() {
13+
return {
14+
greeting: function() {
15+
return greeting;
16+
}
17+
};
18+
}
19+
};
20+
}

app/main/mainService.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
angular.module('mainModule')
4+
.factory('mainService', function() {
5+
var greeting;
6+
return {
7+
setGreeting: function(value) {
8+
greeting = value;
9+
},
10+
getGreeting: function() {
11+
return greeting;
12+
}
13+
};
14+
}
15+
);

app/main/mainValue.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict';
2+
3+
angular.module('mainModule')
4+
.value('mainValue', 'Hello, world!');

app/main/mainView.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>{{greeting}}</h1>

karma.conf.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//jshint strict: false
2+
module.exports = function(config) {
3+
config.set({
4+
5+
basePath: '.',
6+
7+
files: [
8+
'app/lib/jquery/dist/jquery.js',
9+
'app/lib/angular/angular.js',
10+
'app/lib/angular-route/angular-route.js',
11+
'app/lib/angular-sanitize/angular-sanitize.js',
12+
'node_modules/angular-mocks/angular-mocks.js',
13+
'app/lib/bootstrap/dist/js/bootstrap.js',
14+
'app/main/mainModule.js',
15+
'app/main/mainValue.js',
16+
'app/main/mainService.js',
17+
'app/main/mainProvider.js',
18+
'app/main/mainFilter.js',
19+
'app/main/mainController.js',
20+
'app/main/mainDirective.js',
21+
'app/app.js',
22+
'test/**/*Spec.js'
23+
],
24+
25+
exclude: [
26+
'**/*~'
27+
],
28+
29+
frameworks: ['jasmine'],
30+
31+
browsers: [
32+
'Chrome',
33+
'Firefox',
34+
'PhantomJS'
35+
],
36+
37+
reporters: ['progress'],
38+
39+
});
40+
};

0 commit comments

Comments
 (0)