-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add infrastructure to allow for testing, and a build step
The build step allows us to have external dependencies, and selectively compile them into the distribution source for consumption by other software. Add unit tests, and inject http (jquery ajax method provider) dependency Since we inject jquery (or some substitute) in the constructor, we no longer depend on "real" jquery. Thus, we remove it from our bower deps, and other configuration.
- Loading branch information
1 parent
b69e735
commit 1658309
Showing
11 changed files
with
450 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory": "build/bower_components" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
build | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/*global module:false*/ | ||
module.exports = function(grunt) { | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
// Metadata. | ||
pkg: grunt.file.readJSON('package.json'), | ||
|
||
jshint: { | ||
options: { | ||
curly: true, | ||
eqeqeq: true, | ||
immed: true, | ||
latedef: true, | ||
newcap: true, | ||
noarg: true, | ||
sub: true, | ||
undef: true, | ||
unused: true, | ||
boss: true, | ||
eqnull: true, | ||
browser: true, | ||
expr: true, | ||
trailing: true, | ||
}, | ||
gruntfile: { | ||
src: 'Gruntfile.js', | ||
options: { | ||
globals: { | ||
require: false, | ||
}, | ||
}, | ||
}, | ||
lib: { | ||
src: ['lib/**/*.js'], | ||
options: { | ||
globals: { | ||
requirejs: false, | ||
define: false, | ||
window: false, | ||
}, | ||
}, | ||
}, | ||
spec: { | ||
src: ['spec/**/*.js'], | ||
options: { | ||
globals: { | ||
requirejs: false, | ||
describe: false, | ||
it: false, | ||
xit: false, | ||
context: false, | ||
before: false, | ||
beforeEach: false, | ||
after: false, | ||
afterEach: false, | ||
define: false, | ||
expect: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
karma: { | ||
options: { | ||
configFile: 'karma.conf.js' | ||
}, | ||
unit: { | ||
coverageReporter: { | ||
type: 'text-summary' | ||
} | ||
}, | ||
coverage: { | ||
coverageReporter: { | ||
type: 'html' | ||
} | ||
}, | ||
}, | ||
|
||
watch: { | ||
gruntfile: { | ||
files: '<%= jshint.gruntfile.src %>', | ||
tasks: ['jshint:gruntfile'] | ||
}, | ||
dev: { | ||
files: ['lib/**/*.js', 'spec/**/*.js', 'lib/**/*.html'], | ||
tasks: ['build', 'karma:unit', 'jshint'] | ||
}, | ||
copy: { | ||
files: [ | ||
'app/lib', | ||
], | ||
tasks: ['copy:dev'], | ||
}, | ||
bower: { | ||
files: ['bower.json'], | ||
tasks: ['build:full', 'karma:unit', 'jshint'], | ||
}, | ||
}, | ||
|
||
copy: { | ||
dev: { | ||
files: [ | ||
{expand: true, cwd: 'lib', src: ['**/*.js'], dest: 'build'}, | ||
{expand: true, cwd: 'lib', src: ['**/*.json'], dest: 'build'}, | ||
], | ||
}, | ||
dist: { | ||
files: [ | ||
], | ||
}, | ||
}, | ||
|
||
requirejs: { | ||
compile: { | ||
options: { | ||
baseUrl: 'build', | ||
name: 'json-gcs', | ||
mainConfigFile: 'build/json-gcs.js', | ||
out: 'dist/json-gcs.js', | ||
optimize: 'uglify2', | ||
}, | ||
}, | ||
}, | ||
|
||
bower: { | ||
install: { | ||
} | ||
}, | ||
|
||
clean: ['.tmp', 'build', 'coverage'], | ||
}); | ||
|
||
// These plugins provide necessary tasks. | ||
// load all grunt tasks matching the `grunt-*` pattern | ||
require('load-grunt-tasks')(grunt); | ||
|
||
// Build tasks. | ||
grunt.registerTask('build', ['copy:dev']); | ||
grunt.registerTask('build:full', ['clean', 'build', 'bower:install']); | ||
grunt.registerTask('build:dist', ['clean', 'copy:dev', 'bower:install', 'requirejs']); | ||
|
||
// Default task. | ||
grunt.registerTask('default', ['build:full', 'karma:unit', 'jshint']); | ||
grunt.registerTask('coverage', 'Detailed test coverage information', ['build:full', 'karma:coverage']); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
{ | ||
"name": "json-gcs", | ||
"version": "0.0.0", | ||
"homepage": "https://github.com/clalimarmo/json-gcs", | ||
"authors": [ | ||
"Carlos Lalimarmo <[email protected]>" | ||
], | ||
"description": "Store JSON documents to Google Cloud Storage", | ||
"main": "dist/json-gcs.js", | ||
"dependencies": { | ||
"jquery": "~2.1.1" | ||
}, | ||
"dependencies": {}, | ||
"moduleType": [ | ||
"amd" | ||
], | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Karma configuration | ||
// Generated on Thu Feb 06 2014 09:46:59 GMT-0500 (EST) | ||
|
||
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: [ | ||
// NB: requirejs should come before chai in the list below, to avoid a | ||
// known issue: https://github.com/xdissent/karma-chai/issues/5 | ||
'requirejs', | ||
'mocha', | ||
'chai', | ||
], | ||
|
||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
//our code | ||
{pattern: 'build/**/*.js', included: false}, | ||
{pattern: 'spec/**/*_spec.js', included: false}, | ||
{pattern: 'spec/**/*_spec.coffee', included: false}, | ||
|
||
'spec/main.js', | ||
], | ||
|
||
|
||
// list of files to exclude | ||
exclude: [ | ||
'**/*.swp', | ||
'build/bower_components/**/test/**/*js', //DO NOT run tests for third party libraries | ||
], | ||
|
||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
'spec/**/*.coffee': ['coffee'], | ||
}, | ||
|
||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['dots', 'coverage'], | ||
|
||
coverageReporter: { | ||
reporters:[ | ||
{type: 'html', dir:'coverage/'}, | ||
{type: 'text-summary'}, | ||
], | ||
}, | ||
|
||
|
||
// 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: true, | ||
|
||
|
||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['PhantomJS'], | ||
|
||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: true | ||
}); | ||
}; |
Oops, something went wrong.