|
1 | 1 | import { join } from 'path';
|
2 | 2 | import { run } from 'yeoman-test';
|
3 |
| -import assert from 'yeoman-assert'; |
| 3 | +import * as assert from 'yeoman-assert'; |
4 | 4 |
|
5 | 5 | import { makeLoaderName } from '../src/loader-generator';
|
6 | 6 |
|
7 | 7 | describe('loader generator', () => {
|
8 |
| - it.skip('generates a default loader', async () => { |
9 |
| - const outputDir = await run(join(__dirname, '../loader-generator')); |
10 |
| - const loaderDir = `${outputDir}/my-loader`; |
| 8 | + it('generates a default loader', async () => { |
| 9 | + const loaderName = 'my-test-loader'; |
| 10 | + const outputDir = await run(join(__dirname, '../src/loader-generator')).withPrompts({ |
| 11 | + name: loaderName, |
| 12 | + }); |
| 13 | + const loaderDir = join(outputDir, loaderName); |
11 | 14 | const srcFiles = ['cjs.js', 'index.js'];
|
12 | 15 | const testFiles = ['functional.test.js', 'test-utils.js', 'unit.test.js', 'fixtures/simple-file.js'];
|
13 | 16 | const exampleFiles = ['webpack.config.js', 'src/index.js', 'src/lazy-module.js', 'src/static-esm-module.js'];
|
14 | 17 |
|
15 | 18 | // Check that files in all folders are scaffolded. Checking them separately so we know which directory has the problem
|
16 | 19 | // assert for src files
|
17 |
| - assert.file([...srcFiles.map(file => `${loaderDir}/src/${file}`)]); |
| 20 | + assert.file(srcFiles.map(file => join(loaderDir, 'src', file))); |
18 | 21 |
|
19 | 22 | // assert for test files
|
20 |
| - assert.file([...testFiles.map(file => `${loaderDir}/test/${file}`)]); |
| 23 | + assert.file(testFiles.map(file => join(loaderDir, 'test', file))); |
21 | 24 |
|
22 | 25 | // assert for example files
|
23 |
| - assert.file([...exampleFiles.map(file => `${loaderDir}/examples/simple/${file}`)]); |
| 26 | + assert.file(exampleFiles.map(file => join(loaderDir, 'examples/simple', file))); |
24 | 27 |
|
25 | 28 | // Check the contents of the webpack config and loader file
|
26 | 29 | assert.fileContent([
|
27 |
| - [`${loaderDir}/examples/simple/webpack.config.js`, /resolveLoader: {/], |
28 |
| - [`${loaderDir}/src/index.js`, /export default function loader(source) {/], |
| 30 | + [join(loaderDir, 'examples/simple/webpack.config.js'), /resolveLoader: {/], |
| 31 | + [join(loaderDir, 'src/index.js'), /export default function loader\(source\) {/], |
| 32 | + [join(loaderDir, 'package.json'), new RegExp(loaderName)], |
29 | 33 | ]);
|
30 | 34 |
|
31 | 35 | // higher timeout so travis has enough time to execute
|
|
0 commit comments