Skip to content

Commit 2bd02e9

Browse files
drmikecrowebeeman
authored andcommitted
Providing support for karma/jasmine unit tests.
1 parent 61d146a commit 2bd02e9

5 files changed

Lines changed: 60 additions & 7 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ bower_components
1616
docs
1717
client/coverage
1818
.vagrant
19+
/.project
20+
.cache
21+
.config
22+
.npm

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ Please note, at this moment there is no difference in permissions for admin user
4848
- User management
4949
- Loading indicators [chieffancypants/angular-loading-bar](https://github.com/chieffancypants/angular-loading-bar)?
5050

51+
## Unit Testing using Karma/Jasmine
52+
53+
$ ```node_modules/.bin/karma start client/test/karma.conf.js```
54+
55+
INFO [karma]: Karma v0.12.31 server started at http://localhost:8080/
56+
INFO [launcher]: Starting browser PhantomJS
57+
INFO [PhantomJS 1.9.8 (Linux)]: Connected on socket aLJmRuSNUH2rPfpWgS3l with id 89641972
58+
PhantomJS 1.9.8 (Linux): Executed 1 of 1 SUCCESS (0.007 secs / 0.029 secs)
59+
5160

5261
## TODO:
5362

@@ -138,7 +147,7 @@ This also works with the free hosted MongoDB instances at [compose.io](https://w
138147

139148
If you want to share your work through a Pull Request, be sure to make it a clean branch (one functionality per PR) and base it off master.
140149

141-
If you plan on making a big change or replace a core function with something else it is probably best to first open an issue to discuss it with me. This will enhance the chance of the eventual changes getting merged a lot :)
150+
If you plan on making a big change or replace a core function with something else it is probably best to first open an issue to discuss it with me. This will enhance the chance of the eventual changes getting merged a lot :)
142151

143152
The API is built with [generator-loopback](https://www.npmjs.org/package/generator-loopback).
144153

client/test/karma.conf.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,43 @@ module.exports = function (config) {
1818

1919
// list of files / patterns to load in the browser
2020
files: [
21+
'app/bower_components/jquery/dist/jquery.js',
2122
'app/bower_components/angular/angular.js',
22-
'app/bower_components/angular-mocks/angular-mocks.js',
23-
'app/bower_components/angular-animate/angular-animate.js',
24-
'app/bower_components/angular-cookies/angular-cookies.js',
23+
'app/bower_components/bootstrap/dist/js/bootstrap.js',
2524
'app/bower_components/angular-resource/angular-resource.js',
25+
'app/bower_components/angular-cookies/angular-cookies.js',
2626
'app/bower_components/angular-route/angular-route.js',
2727
'app/bower_components/angular-sanitize/angular-sanitize.js',
28+
'app/bower_components/angular-animate/angular-animate.js',
2829
'app/bower_components/angular-touch/angular-touch.js',
30+
'app/bower_components/angular-ui-router/release/angular-ui-router.js',
31+
'app/bower_components/angular-formly/dist/formly.min.js',
32+
'app/bower_components/angular-toasty/js/ng-toasty.js',
33+
'app/bower_components/angular-file-upload/angular-file-upload.js',
34+
'app/bower_components/angular-filter/dist/angular-filter.js',
35+
'app/bower_components/sweetalert/lib/sweet-alert.js',
36+
'app/bower_components/angular-sweetalert/SweetAlert.js',
37+
'app/bower_components/angular-gravatar/build/md5.js',
38+
'app/bower_components/angular-gravatar/build/angular-gravatar.js',
39+
'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
40+
'app/bower_components/angular-bootstrap-nav-tree/dist/abn_tree_directive.js',
41+
'app/bower_components/codemirror/lib/codemirror.js',
42+
'app/bower_components/codemirror/addon/mode/overlay.js',
43+
'app/bower_components/codemirror/mode/gfm/gfm.js',
44+
'app/bower_components/codemirror/mode/markdown/markdown.js',
45+
'app/bower_components/angular-ui-codemirror/ui-codemirror.js',
46+
'app/bower_components/angular-markdown-directive/markdown.js',
47+
'app/bower_components/angular-elastic/elastic.js',
48+
'app/bower_components/angular-autoFields-bootstrap/autofields.min.js',
49+
'app/bower_components/angular-autoFields-bootstrap/autofields-bootstrap.min.js',
50+
'app/bower_components/angular-gettext/dist/angular-gettext.js',
51+
'app/bower_components/angular-translate/angular-translate.js',
52+
'app/bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',
53+
'app/bower_components/angular-translate-loader-url/angular-translate-loader-url.js',
54+
'app/bower_components/angular-ui-grid/ui-grid.js',
55+
'app/bower_components/angular-loading-bar/build/loading-bar.js',
56+
'app/bower_components/Faker/build/build/faker.js',
57+
'app/bower_components/angular-mocks/angular-mocks.js',
2958
'app/js/*.js',
3059
'app/modules/**/*.js',
3160
'test/**/*.js'
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
'use strict';
22

33
describe('Controller: AboutCtrl', function () {
4+
var AboutCtrl,
5+
scope;
46

57
// load the controller's module
8+
beforeEach(module('ui.router'));
9+
beforeEach(module('gettext'));
10+
beforeEach(module('formly'));
11+
beforeEach(module('angular-loading-bar'));
12+
beforeEach(module('lbServices'));
13+
beforeEach(module('com.module.core'));
14+
beforeEach(module('com.module.settings'));
615
beforeEach(module('com.module.about'));
716

8-
var AboutCtrl,
9-
scope;
1017

1118
// Initialize the controller and a mock scope
1219
beforeEach(inject(function ($controller, $rootScope) {
@@ -17,7 +24,7 @@ describe('Controller: AboutCtrl', function () {
1724
}));
1825

1926
it('should attach a list of awesomeThings to the scope', function () {
20-
expect(scope.awesomeThings.length).toBe(3);
27+
expect(scope.angular).toBeDefined();
2128
});
2229

2330
});

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"cookie-parser": "^1.3.3",
3333
"debug": "^2.1.3",
3434
"errorhandler": "^1.3.3",
35+
"eventemitter3": "0.1.6",
3536
"express-session": "^1.10.2",
3637
"get-env": "^0.4.0",
3738
"grunt": "^0.4.5",
@@ -71,6 +72,7 @@
7172
"loopback-component-storage": "^1.2.0",
7273
"loopback-connector-mongodb": "^1.7.0",
7374
"loopback-datasource-juggler": "^2.16.0",
75+
"nodemon": "^1.3.7",
7476
"passport": "^0.2.1",
7577
"passport-facebook": "^1.0.3",
7678
"passport-google-oauth": "~0.1.5",
@@ -88,6 +90,8 @@
8890
"browserify": "^8.1.3",
8991
"connect-livereload": "^0.5.2",
9092
"jasmine-core": "^2.2.0",
93+
"karma": "^0.12.31",
94+
"karma-cli": "0.0.4",
9195
"karma-coverage": "^0.2.7",
9296
"karma-jasmine": "^0.3.5",
9397
"karma-phantomjs-launcher": "^0.1.4",

0 commit comments

Comments
 (0)