code coverage

This commit is contained in:
Radek Stepan 2014-10-28 22:30:42 -06:00
parent 3a8c154b71
commit 66ed330c2e
16 changed files with 467 additions and 230 deletions

View File

@ -48,6 +48,13 @@ module.exports = (grunt) ->
'public/css/app.min.css': 'public/css/app.css'
'public/css/app.bundle.min.css': 'public/css/app.bundle.css'
'watch':
css:
files: [ 'src/styles/**/*.styl' ]
tasks: [ 'stylus', 'concat' ]
options:
spawn: no
'gh-pages':
options:
base: 'public'
@ -68,7 +75,8 @@ module.exports = (grunt) ->
grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-contrib-cssmin')
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-gh-pages')
# Stylus to CSS, concat all CSS.
grunt.registerTask('css', [

View File

@ -1,28 +1,53 @@
BROWSERIFY = ./node_modules/.bin/browserify
WATCH = ./node_modules/.bin/watchify
SERVER = ./node_modules/.bin/static
MOCHA = ./node_modules/.bin/mocha
COVERALLS = ./node_modules/.bin/coveralls
GRUNT = grunt
# Install dependencies.
install:
npm install
# Watch the app sources and build with source maps.
watch:
./node_modules/.bin/watchify -e ./src/app.coffee -o public/js/app.bundle.js -d -v
$(MAKE) watch-js & $(MAKE) watch-css
# Watch the app.
watch-js:
$(WATCH) -e ./src/app.coffee -o public/js/app.bundle.js -d -v
# Watch the styles.
watch-css:
$(GRUNT) watch
# Serve locally.
serve:
./node_modules/.bin/static public -H '{"Cache-Control": "no-cache, must-revalidate"}'
$(SERVER) public -H '{"Cache-Control": "no-cache, must-revalidate"}'
# Make a minified package.
build:
grunt init
./node_modules/.bin/browserify -e ./src/app.coffee -o public/js/app.bundle.js
grunt css
grunt minify
$(GRUNT) init
$(BROWSERIFY) -e ./src/app.coffee -o public/js/app.bundle.js
$(GRUNT) css
$(GRUNT) minify
# Publish to GitHub Pages.
publish:
grunt gh-pages
$(GRUNT) gh-pages
OPTS = --compilers coffee:coffee-script/register --ui exports --timeout 20000 --slow 15000 --bail
# Run mocha test.
test:
./node_modules/.bin/mocha --compilers coffee:coffee-script/register --reporter spec --ui exports --timeout 20000 --slow 15000 --bail
REPORTER = spec
$(MOCHA) $(OPTS) --reporter $(REPORTER)
# Run code coverage.
coverage:
$(MOCHA) $(OPTS) --reporter $(REPORTER) --require blanket > docs/COVERAGE.html
# Run code coverage and publish to coveralls.
coveralls:
$(MOCHA) $(OPTS) --reporter $(REPORTER) --require blanket | COVERALLS_SERVICE_NAME=MOCHA $(COVERALLS)
.PHONY: test

View File

@ -3,5 +3,6 @@
GitHub Burndown Chart as a service. Answers the question "are my projects on track"?
[![Build Status](http://img.shields.io/codeship/<ID_HERE>.svg?style=flat)](<URL_HERE>)
[![Coverage](http://img.shields.io/coveralls/radekstepan/burnchart/assembly.svg?style=flat)](<https://coveralls.io/r/radekstepan/burnchart>)
[![Dependencies](http://img.shields.io/david/radekstepan/burnchart.svg?style=flat)](https://david-dm.org/radekstepan/burnchart)
[![License](http://img.shields.io/badge/license-AGPL--3.0-red.svg?style=flat)](LICENSE)

355
docs/COVERAGE.html Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,5 @@
#Tasks to do
- [ ] watch CSS too
- [ ] add some product screenshots
- [ ] create notes about how original people can upgrade to burnchart
- [ ] clean up docs, track them on git or using Assembly system?
@ -8,7 +7,6 @@
- [ ] check with austin@assembly.com if my repo looks good to be forked to Assembly
- [ ] move domain to Assembly
- [ ] fork it to Assembly
- [ ] move tests from `radekstepan/github-burndown-chart`
- [ ] landing page for the project and put message on `github-burndown-chart` repo
- [ ] provide a documentation site (because we ref it from hero)
- [ ] track users/make it easy for people to leave feedback
@ -19,6 +17,7 @@
##Backlog
- [ ] one click to go from a project or milestone view to github
- [ ] be able to specify milestone by name (will nicely show in title)
- [ ] focus on form fields style (blue outline etc)
- [ ] switch off `user-select` on buttons

View File

@ -27,6 +27,7 @@
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-uglify": "~0.6.0",
"grunt-contrib-cssmin": "~0.10.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-gh-pages": "~0.9.1",
"coffeeify": "~0.7.0L",
"ractivate": "~0.2.0",
@ -35,12 +36,15 @@
"node-static": "~0.7.6",
"mocha": "~2.0.1",
"mocha-lcov-reporter": "0.0.1",
"blanket": "~1.1.6",
"coveralls": "~2.11.2",
"proxyquire": "~1.0.1",
"coffee-script": "~1.8.0",
"async": "~0.9.0",
"d3": "~3.4.13",
"d3-tip": "Caged/d3-tip",
"proxyquire": "~1.0.1",
"lodash": "~2.4.1",
"director": "~1.2.3",
"firebase": "~1.1.2",
@ -60,5 +64,15 @@
"coffeeify",
"ractivate"
]
},
"config": {
"blanket": {
"loader": "./node-loaders/coffee-script",
"pattern": "src",
"data-cover-never": "node_modules",
"data-cover-flags": {
"engineOnly": true
}
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,6 @@ semver = require 'semver'
Model = require '../utils/ractive/model.coffee'
config = require '../models/config.coffee'
stats = require '../modules/stats.coffee'
date = require '../utils/date.coffee'
user = require './user.coffee'
module.exports = new Model

View File

@ -7,22 +7,3 @@ module.exports =
# Fetch all milestones.
'fetchAll': request.allMilestones
# # Get the current milestone out of many.
# else
# request.allMilestones repo, (err, data) ->
# # Errors?
# return cb err if err
# # Empty warning?
# return cb null, "No open milestones for repo #{repo.path}" unless data.length
# # The first milestone should be ending soonest.
# m = data[0]
# # Filter milestones without due date.
# m = _.rest data, { 'due_on' : null }
# # The first milestone should be ending soonest. Prefer milestones with due dates.
# m = if m[0] then m[0] else data[0]
# # Empty milestone?
# if m.open_issues + m.closed_issues is 0
# return cb null, "No issues for milestone `#{m.title}`"
# cb null, null, m

View File

@ -1,2 +0,0 @@
module.exports =
now: -> new Date().toJSON()

View File

@ -1,6 +1,7 @@
proxy = do require('proxyquire').noCallThru
assert = require 'assert'
path = require 'path'
require 'blanket'
request = {}

12
test/lines.coffee Normal file
View File

@ -0,0 +1,12 @@
proxy = do require('proxyquire').noCallThru
assert = require 'assert'
path = require 'path'
require 'blanket'
lines = require '../src/modules/chart/lines.coffee'
module.exports =
'lines - na': (done) ->
assert.equal 1, 1
do done

View File

@ -1,187 +0,0 @@
proxy = do require('proxyquire').noCallThru
assert = require 'assert'
path = require 'path'
req = {}
milestones = proxy path.resolve(__dirname, '../src/modules/milestones.coffee'),
'./request': req
'./require':
'_': require 'lodash'
'superagent': null
'd3': null
'async': null
'marked': require 'marked'
module.exports =
'milestones - get current from 1': (done) ->
req.all_milestones = (opts, cb) ->
cb null, [
{
'number': 1
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-02-01T00:00:00Z'
}
]
milestones {}, (err, warn, milestone) ->
assert.ifError err
assert.equal milestone.number, 1
do done
'milestones - get current from 1 when milestone has no due date': (done) ->
req.all_milestones = (opts, cb) ->
cb null, [
{
'number': 1
'created_at': '2013-01-01T00:00:00Z'
'due_on': null
}
]
milestones {}, (err, warn, milestone) ->
assert.ifError err
assert.equal milestone.number, 1
do done
# We always take from head because of request params.
'milestones - get current from > 1': (done) ->
req.all_milestones = (opts, cb) ->
cb null, [
{
'number': 2
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-01-15T00:00:00Z'
}
{
'number': 1
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-02-01T00:00:00Z'
}
{
'number': 3
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-02-15T00:00:00Z'
}
]
milestones {}, (err, warn, milestone) ->
assert.ifError err
assert.equal milestone.number, 2
do done
'milestones - get current from > 1 when there are milestones without due date': (done) ->
req.all_milestones = (opts, cb) ->
cb null, [
{
'number': 2
'created_at': '2013-01-01T00:00:00Z'
'due_on': null
}
{
'number': 1
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-02-01T00:00:00Z'
}
{
'number': 3
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-02-15T00:00:00Z'
}
]
milestones {}, (err, warn, milestone) ->
assert.ifError err
assert.equal milestone.number, 1
do done
'milestones - get current when empty': (done) ->
req.all_milestones = (opts, cb) ->
cb null, []
milestones { 'path': 'some/repo' }, (err, warn, milestone) ->
assert.ifError err
assert.equal warn, 'No open milestones for repo some/repo'
do done
'milestones - get current when not found': (done) ->
req.all_milestones = (opts, cb) ->
cb 'Not Found'
milestones {}, (err, warn, milestone) ->
assert.equal err, 'Not Found'
do done
'milestones - get current when no issues': (done) ->
req.all_milestones = (opts, cb) ->
cb null, [
{
'title': 'No issues'
'number': 1
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-02-01T00:00:00Z',
'open_issues': 0,
'closed_issues': 0
}
]
milestones {}, (err, warn, milestone) ->
assert.ifError err
assert.equal warn, 'No issues for milestone `No issues`'
do done
'milestones - get one': (done) ->
m =
'number': 1
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-02-01T00:00:00Z'
req.one_milestone = (opts, number, cb) ->
cb null, m
milestones { 'milestone': 1 }, (err, warn, milestone) ->
assert.ifError err
assert.equal warn, null
assert.deepEqual milestone, m
do done
'milestones - get one (404)': (done) ->
req.one_milestone = (opts, number, cb) ->
cb 'Not Found'
milestones { 'milestone': 9 }, (err, warn, milestone) ->
assert.equal err, 'Not Found'
do done
'milestones - get one when no issues': (done) ->
req.one_milestone = (opts, number, cb) ->
cb null, {
'title': 'No issues'
'number': 1
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-02-01T00:00:00Z',
'open_issues': 0,
'closed_issues': 0
}
milestones { 'milestone': 9 }, (err, warn, milestone) ->
assert.ifError err
assert.equal warn, 'No issues for milestone `No issues`'
do done
'milestones - has description': (done) ->
req.all_milestones = (opts, cb) ->
cb null, [
{
'number': 1
'created_at': '2013-01-01T00:00:00Z'
'due_on': '2013-02-01T00:00:00Z'
'description': 'A description of this <strong>milestone</strong> goes *here*'
}
]
milestones {}, (err, warn, milestone) ->
assert.ifError err
assert.equal milestone.description, 'A description of this <strong>milestone</strong> goes <em>here</em>'
do done

12
test/projects.coffee Normal file
View File

@ -0,0 +1,12 @@
proxy = do require('proxyquire').noCallThru
assert = require 'assert'
path = require 'path'
require 'blanket'
projects = require '../src/models/projects.coffee'
module.exports =
'projects - initializes empty': (done) ->
assert.deepEqual projects.data.list, [ ]
do done

View File

@ -1,6 +1,7 @@
proxy = do require('proxyquire').noCallThru
assert = require 'assert'
path = require 'path'
require 'blanket'
class Sa

18
test/stats.coffee Normal file
View File

@ -0,0 +1,18 @@
proxy = do require('proxyquire').noCallThru
assert = require 'assert'
path = require 'path'
require 'blanket'
stats = require '../src/modules/stats.coffee'
module.exports =
'stats - empty milestone': (done) ->
milestone =
'issues':
'open': { 'size': 0 }
'closed': { 'size': 0 }
{ isEmpty } = stats milestone
assert.equal isEmpty, yes
do done