-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] plugin buffer wasn't flushed before running
- Loading branch information
Showing
14 changed files
with
235 additions
and
133 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
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,14 +1,19 @@ | ||
var gulp = require('gulp'); | ||
var jasmine = require('gulp-jasmine'); | ||
var svgSymbols = require('./index'); | ||
var svgGlob = 'test/source/*.svg'; | ||
|
||
gulp.task('test', function (){ | ||
return gulp.src('test/*.js') | ||
.pipe(jasmine()); | ||
.pipe(jasmine({verbose: true})); | ||
}); | ||
|
||
gulp.task('demo', function (){ | ||
return gulp.src(['test/source/github.svg', 'test/source/codepen.svg']) | ||
return gulp.src(svgGlob) | ||
.pipe(svgSymbols()) | ||
.pipe(gulp.dest('tmp')); | ||
}); | ||
}); | ||
|
||
gulp.task('watch', function (){ | ||
return gulp.watch(svgGlob, ['demo']); | ||
}); |
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
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,8 @@ | ||
.codepen { | ||
width: 24px; | ||
height: 24px; | ||
} | ||
.github { | ||
width: 22px; | ||
height: 24px; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,53 @@ | ||
var fs = require('fs'); | ||
var es = require('event-stream'); | ||
var gulp = require('gulp'); | ||
var path = require('path'); | ||
var gutil = require('gulp-util'); | ||
|
||
var svgSymbols = require('../index.js'); | ||
var srcGlob = 'test/source/*.svg' | ||
|
||
// Use the codepen files for that | ||
describe('gulp-svg-symbols plugin', function () { | ||
beforeEach(function () { | ||
this.output = []; | ||
}); | ||
|
||
it('should produce two files', function(done){ | ||
var that = this; | ||
gulp.src(srcGlob) | ||
.pipe(svgSymbols()) | ||
.pipe(es.mapSync(function (data){ | ||
that.output.push(data); | ||
return data; | ||
})) | ||
.pipe(es.wait(function () { | ||
expect(that.output.length).toEqual(2); | ||
expect(that.output[0].path).toEqual('svg-symbols.svg'); | ||
expect(that.output[1].path).toEqual('svg-symbols.css'); | ||
done(); | ||
})); | ||
}); | ||
|
||
it('should have the right output if called many times', function(done){ | ||
var that = this; | ||
gulp.src(srcGlob) | ||
.pipe(svgSymbols()) | ||
.pipe(es.wait(function () { | ||
gulp.src(srcGlob) | ||
.pipe(svgSymbols()) | ||
.pipe(es.mapSync(function (data){ | ||
that.output.push(data); | ||
return data; | ||
})) | ||
.pipe(es.wait(function () { | ||
var svgOutputFile = fs.readFileSync('test/output/svg-symbols.svg').toString(); | ||
var cssOutputFile = fs.readFileSync('test/output/svg-symbols.css').toString(); | ||
expect(that.output.length).toEqual(2); | ||
expect(that.output[0].contents.toString()).toEqual(svgOutputFile); | ||
expect(that.output[1].contents.toString()).toEqual(cssOutputFile); | ||
done(); | ||
})); | ||
})); | ||
}); | ||
}); |
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,66 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var gutil = require('gulp-util'); | ||
|
||
var config = require('../lib/default-config'); | ||
var formatSvgData = require('../lib/format-svg-data.js'); | ||
var toSvg = require('../lib/svg-data-to-svg-file.js'); | ||
var toCss = require('../lib/svg-data-to-css-file.js'); | ||
|
||
// Use the codepen files for that | ||
describe('transform method with options', function () { | ||
beforeEach(function () { | ||
this.file = new gutil.File({ | ||
base: 'test/source', | ||
cwd: 'test/', | ||
path: 'test/source/codepen.svg', | ||
contents: fs.readFileSync('test/source/codepen.svg') | ||
}); | ||
this.info = { width: 24, | ||
height: 24, | ||
name: 'codepen', | ||
id: 'icon-codepen', | ||
className: '.icon-codepen', | ||
cssWidth : '1.5em', | ||
cssHeight : '1.5em' | ||
}; | ||
this.config = { | ||
svgId: 'icon-%f', | ||
className: '.icon-%f', | ||
fontSize: 16 | ||
} | ||
}); | ||
|
||
it('should gather the right data for a svg file', function (done) { | ||
var that = this; | ||
formatSvgData(this.file, this.config, function (result) { | ||
expect(result.info).toEqual(jasmine.any(Object)); | ||
expect(result.info).toEqual(that.info); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should render the right svg', function (done) { | ||
var that = this; | ||
formatSvgData(this.file, this.config, function (result) { | ||
toSvg([result], function (err, result) { | ||
var outputFile = fs.readFileSync('test/output/codepen-symbol.svg').toString(); | ||
expect(result.path).toEqual('svg-symbols.svg'); | ||
expect(result.contents.toString()).toEqual(outputFile); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should render the right css', function (done) { | ||
var that = this; | ||
formatSvgData(this.file, this.config, function(result){ | ||
toCss([result], function(err, result){ | ||
var outputFile = fs.readFileSync('test/output/codepen-symbol.css').toString(); | ||
expect(result.path).toEqual('svg-symbols.css'); | ||
expect(result.contents.toString()).toEqual(outputFile); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.