Skip to content

Commit

Permalink
Add Unit test using env option
Browse files Browse the repository at this point in the history
  • Loading branch information
kamalbennani committed Mar 13, 2018
1 parent 0844645 commit 4b311ac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions resolvers/webpack/test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,16 @@ describe("config", function () {
.and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'foo.js'))
})

it('finds the config at option env when config is a function', function() {
var settings = {
config: require(path.join(__dirname, './files/webpack.function.config.js')),
env: {
dummy: true,
},
}

expect(resolve('bar', file, settings)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'bar.js'))
})

})
Empty file.
3 changes: 2 additions & 1 deletion resolvers/webpack/test/files/webpack.function.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
var path = require('path')
var pluginsTest = require('webpack-resolver-plugin-test')

module.exports = function() {
module.exports = function(env) {
return {
resolve: {
alias: {
'foo': path.join(__dirname, 'some', 'goofy', 'path', 'foo.js'),
'bar': env ? path.join(__dirname, 'some', 'goofy', 'path', 'bar.js') : undefined,
'some-alias': path.join(__dirname, 'some'),
},
modules: [
Expand Down

0 comments on commit 4b311ac

Please sign in to comment.