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
45 changes: 45 additions & 0 deletions zach/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"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 zach/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build/
test/*_bundle.js
4 changes: 4 additions & 0 deletions zach/app/js/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const angular = require('angular');
const app = angular.module('FauxApp', []);

require('./services')(app);
19 changes: 19 additions & 0 deletions zach/app/js/services/error_service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = function(app) {
app.factory('ErrorService', 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 zach/app/js/services/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function(app) {
require('./error_service')(app);
};
41 changes: 41 additions & 0 deletions zach/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const gulp = require('gulp');
const del = require('del');
const webpack = require('webpack-stream');
const eslint = require('gulp-eslint');

const paths = {
html: './app/**/*.html',
js: './app/js/client.js',
tests: './test/error_service_test.js'
};

gulp.task('bundle', ['clean'], () => {
return gulp.src('./app/js/client.js')
.pipe(webpack({output:{filename: 'bundle.js'}}))
.pipe(gulp.dest('build'));
});

gulp.task('clean', () => {
return del('./build/**/*');
});

gulp.task('bundle:test', () => {
return gulp.src(paths.tests)
.pipe(webpack({output:{filename: 'test_bundle.js'}}))
.pipe(gulp.dest('./test'));
});

gulp.task('app-lint', () => {
gulp.src('./app/**/*.js')
.pipe(eslint())
.pipe(eslint.format());
});

gulp.task('test-lint', () => {
gulp.src('./test/**/*_test.js')
.pipe(eslint())
.pipe(eslint.format());
});

gulp.task('lint', ['app-lint', 'test-lint']);
gulp.task('default', ['bundle']);
69 changes: 69 additions & 0 deletions zach/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 18:02:54 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
})
}
27 changes: 27 additions & 0 deletions zach/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "zach",
"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",
"del": "^2.2.1",
"gulp": "^3.9.1",
"gulp-eslint": "^2.0.0",
"jasmine-core": "^2.4.1",
"karma": "^1.1.0",
"karma-chrome-launcher": "^1.0.1",
"karma-jasmine": "^1.0.2",
"webpack-stream": "^3.2.0"
}
}
26 changes: 26 additions & 0 deletions zach/test/error_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');

describe('error service tests', function() {
let errorService;
beforeEach(() => {
angular.mock.module('FauxApp');
angular.mock.inject(function(ErrorService) {
errorService = ErrorService;
});
});
it('should have a getter', () => {
expect(typeof errorService.getErrors).toBe('function');
});
it('getError, called, should get an array', () => {
expect(Array.isArray(errorService.getErrors())).toBe(true);
});
it('logError should add an error to the log', () => {
errorService.logError('test error')({});
let errorArray = errorService.getErrors();
expect(errorArray[0]).toBe('test error');
});
});