Path: blob/main/resolvers/webpack/test/root.js
829 views
'use strict';12const chai = require('chai');3const expect = chai.expect;4const path = require('path');56const resolve = require('../index').resolve;789const file = path.join(__dirname, 'files', 'src', 'dummy.js');10const webpackDir = path.join(__dirname, 'different-package-location');1112describe('root', function () {13it('works', function () {14expect(resolve('main-module', file)).property('path')15.to.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));16});17it('really works', function () {18expect(resolve('jsx/some-file', file)).property('path')19.to.equal(path.join(__dirname, 'files', 'src', 'jsx', 'some-file.js'));20});21it('supports definition as an array', function () {22expect(resolve('main-module', file, { config: 'webpack.array-root.config.js' }))23.property('path')24.to.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));25expect(resolve('typeahead', file, { config: 'webpack.array-root.config.js' }))26.property('path')27.to.equal(path.join(__dirname, 'files', 'bower_components', 'typeahead.js'));28});29it('supports definition as a function', function () {30expect(resolve('main-module', file, { config: 'webpack.function.config.js' }))31.property('path')32.to.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));33expect(resolve('typeahead', file, { config: 'webpack.function.config.js' }))34.property('path')35.to.equal(path.join(__dirname, 'files', 'bower_components', 'typeahead.js'));36});37it('supports passing a different directory to load webpack from', function () {38// Webpack should still be able to resolve the config here39expect(resolve('main-module', file, { config: 'webpack.config.js', cwd: webpackDir }))40.property('path')41.to.equal(path.join(__dirname, 'files', 'src', 'main-module.js'));42expect(resolve('typeahead', file, { config: 'webpack.config.js', cwd: webpackDir }))43.property('path')44.to.equal(path.join(__dirname, 'files', 'bower_components', 'typeahead.js'));45});46});474849