diff --git a/package.json b/package.json index 2b592e1..e6cdd03 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/gzip-plugin.js b/src/gzip-plugin.js index 515bc37..e96135e 100644 --- a/src/gzip-plugin.js +++ b/src/gzip-plugin.js @@ -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 diff --git a/test/index.js b/test/index.js index c003fa9..2aaf402 100644 --- a/test/index.js +++ b/test/index.js @@ -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(); });