Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Maddie/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/build/*
**/test/*_bundle*
*.md
package.json
43 changes: 43 additions & 0 deletions Maddie/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"rules":{
"no-console":0,
"indent":[
2,
2,
{"SwitchCase": 1}
],
"quotes":[
2,
"single"
],
"linebreak-style":[
2,
"unix"
],
"semi":[
2,
"always"
]
},
"env":{
"es6":true,
"node":true,
"browser":true,
"mocha":true,
"jasmine":true
},
"globals":{
"describe":false,
"it":false,
"beforeEach":false,
"afterEach":false,
"before":false,
"after":false
},
"ecmaFeatures":{
"modules":true,
"experimentalObjectRestSpread":true,
"impliedStrict":true
},
"extends":"eslint:recommended"
}
3 changes: 3 additions & 0 deletions Maddie/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
test/test_bundle.js
.DS_Store
5 changes: 5 additions & 0 deletions Maddie/app/js/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';
const angular = require('angular');
const app = angular.module('ErrorApp', []);
require('./controller')(app);
require('./services')(app);
5 changes: 5 additions & 0 deletions Maddie/app/js/controller/appController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function(app){
app.controller('appController', function(ErrorHandler){
this.error = ErrorHandler.getErrors();
});
};
3 changes: 3 additions & 0 deletions Maddie/app/js/controller/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function(app){
require('./appController.js')(app);
};
17 changes: 17 additions & 0 deletions Maddie/app/js/services/errorHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = function(app){
app.factory('ErrorHandler', function() {
const service = {};
const errors = [];

service.logError = function(message){
return function(err){
errors.push(message);
console.log(err);
};
};
service.getErrors = function() {
return errors;
};
return service;
});
};
3 changes: 3 additions & 0 deletions Maddie/app/js/services/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function(app){
require('./errorHandler.js')(app);
};
10 changes: 10 additions & 0 deletions Maddie/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

const gulp = require('gulp');
const webpack = require('webpack-stream');

gulp.task('bundle:test', () => {
return gulp.src(__dirname + '/test/service_test.js')
.pipe(webpack({output:{filename:'test_bundle.js'}}))
.pipe(gulp.dest('./test'));
});
69 changes: 69 additions & 0 deletions Maddie/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Karma configuration
// Generated on Wed Jun 29 2016 19:34:02 GMT-0700 (PDT)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
'test/test_bundle.js'
],


// list of files to exclude
exclude: [
],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
24 changes: 24 additions & 0 deletions Maddie/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Maddie",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"angular": "^1.5.7",
"angular-mocks": "^1.5.7",
"gulp": "^3.9.1",
"jasmine-core": "^2.4.1",
"karma": "^1.1.0",
"karma-chrome-launcher": "^1.0.1",
"webpack-stream": "^3.2.0"
}
}
26 changes: 26 additions & 0 deletions Maddie/test/service_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const angular = require('angular');
require('angular-mocks');
require('../app/js/client.js');

describe('service unit test', () => {
let errorHandler;
beforeEach(() => {
angular.mock.module('ErrorApp');
angular.mock.inject(function(ErrorHandler){
errorHandler = ErrorHandler;
});
});
it('should be a function', () => {
expect(typeof errorHandler.getErrors).toBe('function');
});
it('should get an array', () => {
expect(Array.isArray(errorHandler.getErrors())).toBe(true);
});
it('should add an error to the log', () => {
errorHandler.logError('test')({});
let errorArray = errorHandler.getErrors();
expect(errorArray[0]).toBe('test');
});
});