From 92e58777f282062f6d6c0ed40e7afbb5d88091d7 Mon Sep 17 00:00:00 2001 From: Shuvalov Anton Date: Tue, 6 Oct 2015 00:38:14 +0300 Subject: [PATCH] re #16 add coverage tests --- .gitignore | 2 ++ .travis.yml | 2 ++ package.json | 8 +++++++- test.js | 13 +++++++++++-- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8258172..28445a8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ ._* node_modules npm-debug.log +index-cov.js +coverage.html diff --git a/.travis.yml b/.travis.yml index 7ab627a..62f2968 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,5 @@ language: node_js node_js: - "0.10" - "0.12" +after_success: + - npm run coveralls diff --git a/package.json b/package.json index 0fcaa56..f7424ab 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,10 @@ "description": "Pretty simple mocks for the CRUD and REST API", "main": "index.js", "scripts": { - "test": "mocha" + "test": "mocha", + "make-cov": "jscoverage index.js index-cov.js", + "cov": "npm run make-cov; SM_COV=1 mocha -R html-cov > coverage.html", + "coveralls": "npm run make-cov; SM_COV=1 mocha -R mocha-lcov-reporter | coveralls" }, "repository": { "type": "git", @@ -25,7 +28,10 @@ }, "homepage": "https://github.com/shuvalov-anton/superagent-mocker", "devDependencies": { + "coveralls": "^2.11.4", + "jscoverage": "^0.6.0", "mocha": "^2.2.4", + "mocha-lcov-reporter": "^1.0.0", "should": "^6.0.1", "superagent": "^1.2.0" }, diff --git a/test.js b/test.js index b39fffb..1834e39 100644 --- a/test.js +++ b/test.js @@ -6,9 +6,11 @@ * Dependencies */ var request = require('superagent'); -var mock = require('./')(request); var should = require('should'); -var noop = function() {}; +var mock = process.env.SM_COV + ? require('./index-cov')(request) + : require('./index')(request); + describe('superagent mock', function() { @@ -198,3 +200,10 @@ describe('superagent mock', function() { }); }); + + + +/** + * Just noop + */ +function noop() {};