Skip to content

Commit

Permalink
Added coverage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Feb 11, 2014
1 parent c5d9dbe commit 372ac90
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@
node_modules/
test/results
.git
.coveralls.yml
1 change: 1 addition & 0 deletions .npmignore
Expand Up @@ -2,4 +2,5 @@
*.swp
node_modules/
.git
.coveralls.yml
tests/results
4 changes: 3 additions & 1 deletion README.md
@@ -1,6 +1,8 @@
# gulp-svgicons2svgfont [![NPM version](https://badge.fury.io/js/gulp-svgicons2svgfont.png)](https://npmjs.org/package/gulp-svgicons2svgfont) [![Build status](https://api.travis-ci.org/nfroidure/gulp-svgiconstosvgfont.png)](https://travis-ci.org/nfroidure/gulp-svgicons2svgfont)
# gulp-svgicons2svgfont
> Create an SVG font from several SVG icons with [Gulp](http://gulpjs.com/).
[![NPM version](https://badge.fury.io/js/gulp-svgicons2svgfont.png)](https://npmjs.org/package/gulp-svgicons2svgfont) [![Build status](https://secure.travis-ci.org/nfroidure/gulp-svgicons2svgfont.png)](https://travis-ci.org/nfroidure/gulp-svgicons2svgfont) [![Dependency Status](https://david-dm.org/nfroidure/gulp-svgicons2svgfont.png)](https://david-dm.org/nfroidure/gulp-svgicons2svgfont) [![devDependency Status](https://david-dm.org/nfroidure/gulp-svgicons2svgfont/dev-status.png)](https://david-dm.org/nfroidure/gulp-svgicons2svgfont#info=devDependencies) [![Coverage Status](https://coveralls.io/repos/nfroidure/gulp-svgicons2svgfont/badge.png?branch=master)](https://coveralls.io/r/nfroidure/gulp-svgicons2svgfont?branch=master)

## Usage

First, install `gulp-svgicons2svgfont` as a development dependency:
Expand Down
17 changes: 11 additions & 6 deletions package.json
Expand Up @@ -4,7 +4,9 @@
"description": "Create a SVG font from several SVG icons",
"main": "src/index.js",
"scripts": {
"test": "node_modules/mocha/bin/mocha tests/*.mocha.js"
"test": "./node_modules/mocha/bin/mocha tests/*.mocha.js",
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- tests/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"cover": "istanbul cover ./node_modules/mocha/bin/_mocha --report html -- tests/*.mocha.js -R spec -t 5000"
},
"keywords": [
"gulpplugin",
Expand Down Expand Up @@ -32,13 +34,16 @@
}
],
"dependencies": {
"gulp-util": "~2.2.0",
"gulp-util": "~2.2.14",
"svgicons2svgfont": "0.0.5"
},
"devDependencies": {
"event-stream": "~3.0.20",
"mocha": "~1.16.2",
"gulp": "~3.2.1",
"rimraf": "~2.2.5"
"mocha": "~1.17.1",
"event-stream": "~3.1.0",
"mocha-lcov-reporter": "0.0.1",
"coveralls": "~2.7.1",
"istanbul": "~0.2.4",
"gulp": "*",
"rimraf": "*"
}
}
12 changes: 6 additions & 6 deletions src/index.js
Expand Up @@ -18,13 +18,19 @@ module.exports = function(options) {
if (!options.fontName) {
throw new gutil.PluginError('svgicons2svgfont', 'Missing options.fontName');
}

options.log = function() {
gutil.log.apply(gutil, ['gulp-svgicons2svgfont: '].concat(
[].slice.call(arguments, 0).concat()));
};

var stream = new Stream.Transform({objectMode: true});

options.error = function() {
stream.emit('error', new PluginError('svgicons2svgfont',
[].slice.call(arguments, 0).concat()));
};

// Collecting icons
stream._transform = function bufferContents(file, unused, done) {
// When null just pass through
Expand All @@ -50,12 +56,6 @@ module.exports = function(options) {
// No icons, exit
if (files.length === 0) return done();

// Wrap error function
options.error = function() {
stream.emit('error', new PluginError('svgicons2svgfont',
[].slice.call(arguments, 0).concat()));
};

// Map each icons to their corresponding glyphs
var glyphs = files.map(function(file) {
// Creating an object for each icon
Expand Down
9 changes: 9 additions & 0 deletions tests/tests.mocha.js
Expand Up @@ -354,4 +354,13 @@ describe('gulp-svgicons2svgfont', function() {
});


describe('must throw error when not fontname', function() {

assert.throws(function() {
svgicons2svgfont();
});

});


});

0 comments on commit 372ac90

Please sign in to comment.