From 4c863589f17c100147963e5c88f370ab3a9e186f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFC=20DIRINGER?= Date: Wed, 19 Jul 2017 16:01:28 +0200 Subject: [PATCH 1/4] Fix missing tsloader return statement --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 9eea6a31..6b38a21f 100644 --- a/index.js +++ b/index.js @@ -372,6 +372,8 @@ module.exports = { */ enableTypeScriptLoader(callback = () => {}) { webpackConfig.enableTypeScriptLoader(callback); + + return this; }, /** From 957e1d0ecf62dc04363db24eb81bba9b454167c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFC=20DIRINGER?= Date: Thu, 20 Jul 2017 10:14:03 +0200 Subject: [PATCH 2/4] Add tests for the public API --- test/api.js | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 test/api.js diff --git a/test/api.js b/test/api.js new file mode 100644 index 00000000..52676f67 --- /dev/null +++ b/test/api.js @@ -0,0 +1,206 @@ +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +'use strict'; + +const expect = require('chai').expect; +require('../lib/context').runtimeConfig = {}; +const api = require('../index.js'); + +describe('Public API', () => { + + describe('setOutputPath', () => { + + it('must return the API object', () => { + const returnedValue = api.setOutputPath('/'); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('setPublicPath', () => { + + it('must return the API object', () => { + const returnedValue = api.setPublicPath('/'); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('setManifestKeyPrefix', () => { + + it('must return the API object', () => { + const returnedValue = api.setManifestKeyPrefix('/build'); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('addEntry', () => { + + it('must return the API object', () => { + const returnedValue = api.addEntry('entry', 'main.js'); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('addStyleEntry', () => { + + it('must return the API object', () => { + const returnedValue = api.addStyleEntry('styleEntry', 'main.css'); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('addPlugin', () => { + + it('must return the API object', () => { + const returnedValue = api.addPlugin(null); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('addLoader', () => { + + it('must return the API object', () => { + const returnedValue = api.addLoader(null); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('addRule', () => { + + it('must return the API object', () => { + const returnedValue = api.addRule(null); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('enableVersioning', () => { + + it('must return the API object', () => { + const returnedValue = api.enableVersioning(); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('enableSourceMaps', () => { + + it('must return the API object', () => { + const returnedValue = api.enableSourceMaps(); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('createSharedEntry', () => { + + it('must return the API object', () => { + const returnedValue = api.createSharedEntry('sharedEntry', 'vendor.js'); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('autoProvideVariables', () => { + + it('must return the API object', () => { + const returnedValue = api.autoProvideVariables({}); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('autoProvidejQuery', () => { + + it('must return the API object', () => { + const returnedValue = api.autoProvidejQuery(); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('enablePostCssLoader', () => { + + it('must return the API object', () => { + const returnedValue = api.enablePostCssLoader(); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('enableSassLoader', () => { + + it('must return the API object', () => { + const returnedValue = api.enableSassLoader(); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('enableLessLoader', () => { + + it('must return the API object', () => { + const returnedValue = api.enableLessLoader(); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('setOutputPath', () => { + + it('must return the API object', () => { + const returnedValue = api.configureBabel(() => {}); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('enableReactPreset', () => { + + it('must return the API object', () => { + const returnedValue = api.enableReactPreset(); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('enableTypeScriptLoader', () => { + + it('must return the API object', () => { + const returnedValue = api.enableTypeScriptLoader(); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('enableVueLoader', () => { + + it('must return the API object', () => { + const returnedValue = api.enableVueLoader(); + expect(returnedValue).to.equal(api); + }); + + }); + + describe('cleanupOutputBeforeBuild', () => { + + it('must return the API object', () => { + const returnedValue = api.cleanupOutputBeforeBuild(); + expect(returnedValue).to.equal(api); + }); + + }); +}); From e2b8bef5eef96bbf2e09f8274d48ff6a70b196b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFC=20DIRINGER?= Date: Thu, 20 Jul 2017 10:23:37 +0200 Subject: [PATCH 3/4] Remove trailing spaces (lint) --- test/api.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/test/api.js b/test/api.js index 52676f67..0b16730a 100644 --- a/test/api.js +++ b/test/api.js @@ -30,7 +30,7 @@ describe('Public API', () => { const returnedValue = api.setPublicPath('/'); expect(returnedValue).to.equal(api); }); - + }); describe('setManifestKeyPrefix', () => { @@ -39,7 +39,7 @@ describe('Public API', () => { const returnedValue = api.setManifestKeyPrefix('/build'); expect(returnedValue).to.equal(api); }); - + }); describe('addEntry', () => { @@ -48,7 +48,7 @@ describe('Public API', () => { const returnedValue = api.addEntry('entry', 'main.js'); expect(returnedValue).to.equal(api); }); - + }); describe('addStyleEntry', () => { @@ -57,7 +57,7 @@ describe('Public API', () => { const returnedValue = api.addStyleEntry('styleEntry', 'main.css'); expect(returnedValue).to.equal(api); }); - + }); describe('addPlugin', () => { @@ -66,7 +66,7 @@ describe('Public API', () => { const returnedValue = api.addPlugin(null); expect(returnedValue).to.equal(api); }); - + }); describe('addLoader', () => { @@ -75,7 +75,7 @@ describe('Public API', () => { const returnedValue = api.addLoader(null); expect(returnedValue).to.equal(api); }); - + }); describe('addRule', () => { @@ -84,7 +84,7 @@ describe('Public API', () => { const returnedValue = api.addRule(null); expect(returnedValue).to.equal(api); }); - + }); describe('enableVersioning', () => { @@ -93,7 +93,7 @@ describe('Public API', () => { const returnedValue = api.enableVersioning(); expect(returnedValue).to.equal(api); }); - + }); describe('enableSourceMaps', () => { @@ -102,7 +102,7 @@ describe('Public API', () => { const returnedValue = api.enableSourceMaps(); expect(returnedValue).to.equal(api); }); - + }); describe('createSharedEntry', () => { @@ -111,7 +111,7 @@ describe('Public API', () => { const returnedValue = api.createSharedEntry('sharedEntry', 'vendor.js'); expect(returnedValue).to.equal(api); }); - + }); describe('autoProvideVariables', () => { @@ -120,7 +120,7 @@ describe('Public API', () => { const returnedValue = api.autoProvideVariables({}); expect(returnedValue).to.equal(api); }); - + }); describe('autoProvidejQuery', () => { @@ -129,7 +129,7 @@ describe('Public API', () => { const returnedValue = api.autoProvidejQuery(); expect(returnedValue).to.equal(api); }); - + }); describe('enablePostCssLoader', () => { @@ -138,7 +138,7 @@ describe('Public API', () => { const returnedValue = api.enablePostCssLoader(); expect(returnedValue).to.equal(api); }); - + }); describe('enableSassLoader', () => { @@ -147,7 +147,7 @@ describe('Public API', () => { const returnedValue = api.enableSassLoader(); expect(returnedValue).to.equal(api); }); - + }); describe('enableLessLoader', () => { @@ -156,7 +156,7 @@ describe('Public API', () => { const returnedValue = api.enableLessLoader(); expect(returnedValue).to.equal(api); }); - + }); describe('setOutputPath', () => { @@ -165,7 +165,7 @@ describe('Public API', () => { const returnedValue = api.configureBabel(() => {}); expect(returnedValue).to.equal(api); }); - + }); describe('enableReactPreset', () => { @@ -174,7 +174,7 @@ describe('Public API', () => { const returnedValue = api.enableReactPreset(); expect(returnedValue).to.equal(api); }); - + }); describe('enableTypeScriptLoader', () => { @@ -183,7 +183,7 @@ describe('Public API', () => { const returnedValue = api.enableTypeScriptLoader(); expect(returnedValue).to.equal(api); }); - + }); describe('enableVueLoader', () => { @@ -192,7 +192,7 @@ describe('Public API', () => { const returnedValue = api.enableVueLoader(); expect(returnedValue).to.equal(api); }); - + }); describe('cleanupOutputBeforeBuild', () => { @@ -201,6 +201,6 @@ describe('Public API', () => { const returnedValue = api.cleanupOutputBeforeBuild(); expect(returnedValue).to.equal(api); }); - + }); }); From dca4c9d21de27c1d3b48fded53b8eaaa84cfbfaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFC=20DIRINGER?= Date: Thu, 20 Jul 2017 13:56:44 +0200 Subject: [PATCH 4/4] Rename test/api.js to test/index.js to match the tested file name --- test/{api.js => index.js} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/{api.js => index.js} (99%) diff --git a/test/api.js b/test/index.js similarity index 99% rename from test/api.js rename to test/index.js index 0b16730a..d1d2b444 100644 --- a/test/api.js +++ b/test/index.js @@ -11,7 +11,7 @@ const expect = require('chai').expect; require('../lib/context').runtimeConfig = {}; -const api = require('../index.js'); +const api = require('../index'); describe('Public API', () => {