Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
add coverage-api build target. Only runs high level tests.
Browse files Browse the repository at this point in the history
Should help expose unnecessary code.
  • Loading branch information
jamestalmage committed Dec 19, 2014
1 parent 9ce6b75 commit 9b3b2bb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 35 deletions.
51 changes: 26 additions & 25 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,44 @@ var gulp = require('gulp');
var gutil = require('gulp-util');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var _ = require('lodash');

gulp.task('mocha',mochaTask);
gulp.task('coverage',coverageTask);
gulp.task('coverage',coverage());
gulp.task('coverage-api',coverage({grep:'@api'}));

gulp.task('watch-mocha',function(){
gulp.watch(['test/**','src/**'],['mocha']);
mochaTask();
});

gulp.task('watch-coverage',function(){
gulp.watch(['test/**','src/**'],['coverage']);
coverageTask();
});

gulp.task('example',function(){
require('./examples/examples')();
});

function coverageTask(cb){
gulp.src(['src/*.js'])
.pipe(istanbul()) // Covering files
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
.on('error', logMochaError)
.on('finish', function () {
var opts = process.env.TRAVIS ? {} : {grep:'original-cli-table', invert:true};

gulp.src(['test/*.js'])
.pipe(mocha(opts))
.on('error',function(err){
logMochaError(err);
if(cb) cb(err);
})
.pipe(istanbul.writeReports()) // Creating the reports after tests run
.on('end', function(){
if(cb) cb();
});
});
function coverage(opts){
opts = opts || {};

function coverageTask(cb){
gulp.src(['src/*.js'])
.pipe(istanbul()) // Covering files
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
.on('error', logMochaError)
.on('finish', function () {
gulp.src(['test/*.js'])
.pipe(mocha(opts))
.on('error',function(err){
logMochaError(err);
if(cb) cb(err);
})
.pipe(istanbul.writeReports()) // Creating the reports after tests run
.on('end', function(){
if(cb) cb();
});
});
}

return coverageTask;
}

function mochaTask(){
Expand Down
2 changes: 1 addition & 1 deletion test/original-cli-table-index-tests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('original-cli-table index tests',function(){
describe('@api original-cli-table index tests',function(){
var Table = require('../src/table');
var chai = require('chai');
var expect = chai.expect;
Expand Down
2 changes: 1 addition & 1 deletion test/original-cli-table-newlines-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('original-cli-table newline tests',function(){
describe('@api original-cli-table newline tests',function(){
var Table = require('../src/table');
var chai = require('chai');
var expect = chai.expect;
Expand Down
14 changes: 7 additions & 7 deletions test/table-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('Table', function () {
describe('@api Table', function () {
var Table = require('../src/table');
var chai = require('chai');
var expect = chai.expect;
Expand Down Expand Up @@ -52,14 +52,14 @@ describe('Table', function () {
var table = new Table({style:{head:[],border:[]}});

table.push(
[{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings'},'hello'],
[{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings',vAlign:'center'},'hello'],
['howdy']
);

var expected = [
'┌───────────┬───────────┬───────┐'
, '│ greetings │ greetings │ hello │'
, '│ │ ├───────┤'
, '│ greetings │ │ hello │'
, '│ │ greetings ├───────┤'
, '│ │ │ howdy │'
, '└───────────┴───────────┴───────┘'
];
Expand All @@ -71,15 +71,15 @@ describe('Table', function () {
var table = new Table({style:{head:[],border:[]}});

table.push(
['hello',{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings'}],
['hello',{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings',vAlign:'bottom'}],
['howdy']
);

var expected = [
'┌───────┬───────────┬───────────┐'
, '│ hello │ greetings │ greetings │'
, '│ hello │ greetings │ │'
, '├───────┤ │ │'
, '│ howdy │ │ │'
, '│ howdy │ │ greetings │'
, '└───────┴───────────┴───────────┘'
];

Expand Down
2 changes: 1 addition & 1 deletion test/verify-legacy-compatibility-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
commonTests(require('cli-table'));
});

describe('cli-table2 matches verified behavior',function(){
describe('@api cli-table2 matches verified behavior',function(){
commonTests(require('../src/table'));
});

Expand Down

0 comments on commit 9b3b2bb

Please sign in to comment.