Skip to content

Commit

Permalink
tests improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsopacifer committed Aug 30, 2016
1 parent 09bec0b commit 30eb410
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 5 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
node_modules
.DS_Store
node_modules/
npm-debug.log
# Coverage reports
coverage
coverage/
coverage/*
out/
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ module.exports = (opts = {}) => {
return cb(new PluginError(pluginName, 'Streams not supported!'));
}

const config = opts;

const banana = require('bananacss')(config);
const banana = require('bananacss')(opts);

const renderedContents = banana.render(file.contents.toString(), file.path);

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"eslint": "^3.2.2",
"istanbul": "^0.4.4",
"mocha": "^3.0.0",
"mocha-lcov-reporter": "^1.2.0"
"mocha-lcov-reporter": "^1.2.0",
"vinyl": "^1.2.0"
}
}
Empty file removed test/.keep
Empty file.
59 changes: 59 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const assert = require('assert');
const File = require('vinyl');
const banana = require('../');

describe('gulp-banana', () => {

it('Should return a compiled css.', (done) => {

const fakeFile = new File({
contents: new Buffer('.foo{bnn-size: 100%;}'),
path: '/fake_path/file.bnn'
});

const stream = banana();

stream.write(fakeFile);

stream.on('data', (file) => {

assert(file.isBuffer());

const result = file.contents.toString();
const expect = '.foo {\n width: 100%;\n height: 100%;\n}';

assert.equal(result, expect);

done();

});

});

it('Should return a compiled css (minify).', (done) => {

const fakeFile = new File({
contents: new Buffer('.foo{bnn-size: 100%;}'),
path: '/fake_path/file.bnn'
});

const stream = banana({compress: true});

stream.write(fakeFile);

stream.on('data', (file) => {

assert(file.isBuffer());

const result = file.contents.toString();
const expect = '.foo{width:100%;height:100%;}';

assert.equal(result, expect);

done();

});

});

});

0 comments on commit 30eb410

Please sign in to comment.