-
-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathsubgenerator.js
41 lines (36 loc) · 1.09 KB
/
subgenerator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const fs = require('fs');
jest.mock('superb', () => ({ random: () => "cat's meow" }));
describe('generator:subgenerator', () => {
beforeEach(() => {
return helpers
.run(path.join(__dirname, '../subgenerator'))
.withArguments(['foo'])
.withOptions({
force: true
})
.inTmpDir(tmpDir => {
fs.writeFileSync(
path.join(tmpDir, 'package.json'),
'{"name": "generator-foo", "files":[]}'
);
});
});
it('creates files', () => {
assert.file([
'generators/foo/index.js',
'generators/foo/templates/dummyfile.txt',
'__tests__/foo.js'
]);
});
it('configures the test file', () => {
assert.fileContent('__tests__/foo.js', "describe('generator-foo:foo");
assert.fileContent('__tests__/foo.js', '../generators/foo');
});
it('escapes possible apostrophes from superb', () => {
assert.fileContent('generators/foo/index.js', "Welcome to the cat\\'s meow");
});
});