Skip to content

Commit 506e27e

Browse files
committed
zawui09
1 parent 500df53 commit 506e27e

File tree

4 files changed

+200
-44
lines changed

4 files changed

+200
-44
lines changed

frontend/karma.conf.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = function(config) {
2+
config.set({
3+
basePath: '',
4+
frameworks: ['jasmine'],
5+
files: [{
6+
pattern: 'spec.bundle.js',
7+
watched: false
8+
}],
9+
exclude: [],
10+
plugins: [
11+
require("karma-jasmine"),
12+
require("karma-phantomjs-launcher"),
13+
require("karma-spec-reporter"),
14+
require("karma-sourcemap-loader"),
15+
require("karma-webpack")
16+
],
17+
preprocessors: {
18+
'spec.bundle.js': ['webpack', 'sourcemap']
19+
},
20+
webpack: {
21+
devtool: 'inline-source-map',
22+
module: {
23+
loaders: [{
24+
test: /\.js/,
25+
exclude: [/app\/lib/, /node_modules/],
26+
loader: 'babel'
27+
}, {
28+
test: /\.html/,
29+
loader: 'raw'
30+
}, {
31+
test: /\.styl$/,
32+
loader: 'style!css!stylus'
33+
}, {
34+
test: /\.css$/,
35+
loader: 'style!css'
36+
}]
37+
}
38+
},
39+
webpackServer: {
40+
noInfo: true // prevent console spamming when running in Karma!
41+
},
42+
reporters: ['spec'],
43+
port: 9876,
44+
colors: true,
45+
logLevel: config.LOG_INFO,
46+
autoWatch: false,
47+
browsers: ['PhantomJS'],
48+
singleRun: true
49+
});
50+
};

frontend/package.json

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,63 @@
11
{
2-
"name": "zawui",
3-
"version": "1.0.0",
4-
"description": "",
2+
"name": "eggly-es6",
3+
"version": "0.0.1",
4+
"description": "A simple bookmark manager built on ES6 using AngularJS 1.x, Gulp, and Webpack.",
55
"main": "index.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8-
},
9-
"author": "Javril Bavogui [email protected]",
10-
"license": "ISC",
116
"dependencies": {
12-
"angular": "^1.6.4",
13-
"angular-animate": "^1.6.4",
14-
"angular-ui-router": "^0.4.2",
15-
"bootstrap-css-only": "^3.3.7",
16-
"lodash": "^4.17.4",
17-
"normalize.css": "^6.0.0"
7+
"angular": "1.5.7",
8+
"angular-animate": "1.5.7",
9+
"angular-mocks": "1.5.7",
10+
"angular-ui-router": "^0.3.1",
11+
"bootstrap-css-only": "3.3.6",
12+
"lodash": "^4.13.1",
13+
"normalize.css": "4.1.1"
1814
},
1915
"devDependencies": {
20-
"angular-mocks": "^1.6.4",
21-
"babel-core": "^6.24.1",
22-
"babel-loader": "^6.4.1",
23-
"babel-preset-es2015": "^6.24.1",
24-
"browser-sync": "^2.18.8",
25-
"css-loader": "^0.28.0",
26-
"file-loader": "^0.11.1",
16+
"angular-mocks": "1.5.7",
17+
"babel-core": "6.10.4",
18+
"babel-loader": "6.2.4",
19+
"babel-preset-es2015": "^6.9.0",
20+
"browser-sync": "2.13.0",
21+
"css-loader": "0.23.1",
22+
"file-loader": "0.9.0",
2723
"fs-walk": "0.0.1",
28-
"gulp": "^3.9.1",
29-
"gulp-rename": "^1.2.2",
30-
"gulp-template": "^4.0.0",
31-
"jasmine": "^2.5.3",
32-
"jasmine-core": "^2.5.2",
33-
"karma": "^1.6.0",
34-
"karma-jasmine": "^1.1.0",
35-
"karma-phantomjs-launcher": "^1.0.4",
36-
"karma-sourcemap-loader": "^0.3.7",
37-
"karma-spec-reporter": "0.0.31",
38-
"karma-webpack": "^2.0.3",
39-
"ng-annotate-loader": "^0.2.0",
40-
"node-libs-browser": "^2.0.0",
41-
"phantomjs-prebuilt": "^2.1.14",
42-
"raw-loader": "^0.5.1",
43-
"run-sequence": "^1.2.2",
44-
"style-loader": "^0.16.1",
24+
"gulp": "3.9.1",
25+
"gulp-rename": "1.2.2",
26+
"gulp-template": "4.0.0",
27+
"jasmine": "2.4.1",
28+
"jasmine-core": "2.4.1",
29+
"karma": "1.1.0",
30+
"karma-jasmine": "1.0.2",
31+
"karma-phantomjs-launcher": "1.0.1",
32+
"karma-sourcemap-loader": "0.3.7",
33+
"karma-spec-reporter": "0.0.26",
34+
"karma-webpack": "1.7.0",
35+
"ng-annotate-loader": "0.1.0",
36+
"node-libs-browser": "1.0.0",
37+
"phantomjs-prebuilt": "2.1.7",
38+
"raw-loader": "0.5.1",
39+
"run-sequence": "1.2.1",
40+
"style-loader": "0.13.1",
4541
"stylus": "^0.54.5",
46-
"stylus-loader": "^3.0.1",
47-
"url-loader": "^0.5.8",
48-
"webpack": "^2.4.1",
49-
"webpack-stream": "^3.2.0",
50-
"yargs": "^7.1.0"
51-
}
42+
"stylus-loader": "2.1.1",
43+
"url-loader": "0.5.7",
44+
"webpack": "1.13.1",
45+
"webpack-stream": "3.2.0",
46+
"yargs": "4.7.1"
47+
},
48+
"scripts": {
49+
"start": "gulp",
50+
"test": "karma start"
51+
},
52+
"keywords": [
53+
"angular",
54+
"webpack",
55+
"es6"
56+
],
57+
"repository": {
58+
"type": "git",
59+
"url": "https://github.com/simpulton/eggly-es6.git"
60+
},
61+
"author": "Luke Ruebbelke",
62+
"license": "Apache-2.0"
5263
}

frontend/spec.bundle.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* When testing with Webpack and ES6, we have to do some
3+
* preliminary setup. Because we are writing our tests also in ES6,
4+
* we must transpile those as well, which is handled inside
5+
* `karma.conf.js` via the `karma-webpack` plugin. This is the entry
6+
* file for the Webpack tests. Similarly to how Webpack creates a
7+
* `bundle.js` file for the compressed app source files, when we
8+
* run our tests, Webpack, likewise, compiles and bundles those tests here.
9+
*/
10+
11+
import angular from 'angular';
12+
13+
// Built by the core Angular team for mocking dependencies
14+
import mocks from 'angular-mocks';
15+
16+
// We use the context method on `require` which Webpack created
17+
// in order to signify which files we actually want to require or import.
18+
// Below, `context` will be a/an function/object with file names as keys.
19+
// Using that regex, we scan within `src/app` and target
20+
// all files ending with `.spec.js` and trace its path.
21+
// By passing in true, we permit this process to occur recursively.
22+
let context = require.context('./src/app', true, /\.spec\.js/);
23+
24+
// Get all files, for each file, call the context function
25+
// that will require the file and load it here. Context will
26+
// loop and require those spec files here.
27+
context.keys().forEach(context);
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import CategoriesModule from './categories';
2+
import CategoriesController from './categories.controller';
3+
import CategoriesComponent from './categories.component';
4+
import CategoriesTemplate from './categories.html';
5+
6+
describe('Categories', () => {
7+
let component, $componentController, CategoriesModel;
8+
9+
beforeEach(() => {
10+
window.module('categories');
11+
12+
window.module($provide => {
13+
$provide.value('CategoriesModel', {
14+
getCategories: () => {
15+
return {
16+
then: () => {}
17+
};
18+
}
19+
});
20+
});
21+
});
22+
23+
beforeEach(inject((_$componentController_, _CategoriesModel_) => {
24+
CategoriesModel = _CategoriesModel_;
25+
$componentController = _$componentController_;
26+
}));
27+
28+
describe('Module', () => {
29+
it('is named correctly', () => {
30+
expect(CategoriesModule.name).toEqual('categories');
31+
});
32+
});
33+
34+
describe('Controller', () => {
35+
it('calls CategoriesModel.getCategories immediately', () => {
36+
spyOn(CategoriesModel, 'getCategories').and.callThrough();
37+
38+
component = $componentController('categories', {
39+
CategoriesModel
40+
});
41+
component.$onInit();
42+
43+
expect(CategoriesModel.getCategories).toHaveBeenCalled();
44+
});
45+
});
46+
47+
describe('Template', () => {
48+
it('includes the `category-item` directive', () => {
49+
expect(CategoriesTemplate).toContain('category-item');
50+
});
51+
});
52+
53+
describe('Component', () => {
54+
const component = CategoriesComponent;
55+
56+
it('includes the intended template',() => {
57+
expect(component.template).toEqual(CategoriesTemplate);
58+
});
59+
60+
it('uses the correct `controllerAs` label', () => {
61+
expect(component.controllerAs).toBe('categoriesListCtrl');
62+
});
63+
64+
it('invokes the right controller', () => {
65+
expect(component.controller).toEqual(CategoriesController);
66+
});
67+
});
68+
});

0 commit comments

Comments
 (0)