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

Commit

Permalink
major(release): add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <[email protected]>
  • Loading branch information
Charlike Mike Reagent committed Oct 25, 2017
1 parent b0904c0 commit 26e87d1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"devDependencies": {
"hela": "1.3.12",
"hela-config-tunnckocore": "2.0.0",
"isobject": "3.0.1",
"mukla": "0.4.9",
"rollup": "0.50.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/gzip-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function gzip (options) {
const opts = Object.assign({ minSize: 0 }, options);

return {
name: 'gzip',
name: 'just-gzip',

onwrite: (details) => {
// fallbacks for Rollup < 0.48
Expand Down
36 changes: 33 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,38 @@
*/

const test = require('mukla');
const fn = require('../src/index.js');
const isObject = require('isobject');
const plugin = require('../src/index.js');

test('foo bar', () => {
test.ok(fn);
test('returns an object with banner, plugins, external', (done) => {
const opts = plugin();
test.strictEqual(isObject(opts), true);
test.strictEqual(typeof opts.banner, 'string');
test.ok(opts.plugins);
done();
});

test('includes the uglify plugin when opts.uglify: true', (done) => {
const { plugins } = plugin({ uglify: true });
const [uglifyPlugin] = plugins.filter(({ name }) => name === 'uglify');

test.strictEqual(isObject(uglifyPlugin), true);
test.strictEqual(uglifyPlugin.name, 'uglify');
done();
});

test('includes the gzip plugin when opts.gzip: true', (done) => {
const config = plugin({ gzip: true });
const plugins = config.plugins.filter(({ name }) => name === 'just-gzip');

test.strictEqual(plugins.length, 1);
done();
});

test('should includes node-resolve plugin when opts.resolve exist', (done) => {
const cfg = plugin({ resolve: 'pify' });

test.strictEqual(cfg.plugins.length, 3);
test.strictEqual(cfg.plugins[1].name, 'node-resolve');
done();
});

0 comments on commit 26e87d1

Please sign in to comment.