-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(generator): add tests for plugin generator (#1235)
add tests for plugin generator
- Loading branch information
Showing
2 changed files
with
44 additions
and
13 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { join } from 'path'; | ||
import { run } from 'yeoman-test'; | ||
const assert = require('yeoman-assert'); | ||
import { generatePluginName } from '../utils'; | ||
|
||
describe('plugin generator', () => { | ||
it('generates a default plugin', async () => { | ||
const outputDir = await run(join(__dirname, '../plugin-generator')); | ||
const pluginDir = `${outputDir}/my-webpack-plugin`; | ||
const srcFiles = ['cjs.js', 'index.js']; | ||
const testFiles = ['functional.test.js', 'test-utils.js']; | ||
const exampleFiles = ['webpack.config.js', 'src/index.js', 'src/lazy-module.js', 'src/static-esm-module.js']; | ||
|
||
// Check that files in all folders are scaffolded. Checking them separately so we know which directory has the problem | ||
// assert for src files | ||
assert.file([...srcFiles.map(file => `${pluginDir}/src/${file}`)]); | ||
|
||
// assert for test files | ||
assert.file([...testFiles.map(file => `${pluginDir}/test/${file}`)]); | ||
|
||
// assert for example files | ||
assert.file([...exampleFiles.map(file => `${pluginDir}/examples/simple/${file}`)]); | ||
|
||
// Check the contents of the webpack config and loader file | ||
assert.fileContent([ | ||
[`${pluginDir}/examples/simple/webpack.config.js`, 'new MyWebpackPlugin()'], | ||
[`${pluginDir}/src/index.js`, 'MyWebpackPlugin.prototype.apply = function(compiler) {'], | ||
]); | ||
|
||
// higher timeout so travis has enough time to execute | ||
}, 10000); | ||
}); | ||
|
||
describe('generate plugin name', () => { | ||
it('should return webpack Standard Plugin Name for Name : extract-text-webpack-plugin', () => { | ||
const pluginName = generatePluginName('extract-text-webpack-plugin'); | ||
expect(pluginName).toEqual('ExtractTextWebpackPlugin'); | ||
}); | ||
|
||
it('should return webpack Standard Plugin Name for Name : webpack.DefinePlugin', () => { | ||
const pluginName = generatePluginName('webpack.DefinePlugin'); | ||
expect(pluginName).toEqual('webpack.DefinePlugin'); | ||
}); | ||
}); |