forked from RichardLitt/generator-standard-readme
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
85 lines (68 loc) · 2.1 KB
/
test.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import path from 'path'
import test from 'ava'
import helpers from 'yeoman-test'
import assert from 'yeoman-assert'
import pify from 'pify'
import fs from 'graceful-fs'
let generator
test.beforeEach(async () => {
await pify(helpers.testDirectory)(path.join(__dirname, 'temp'))
generator = helpers.createGenerator('standard-readme:app', ['../app'], null, {skipInstall: true})
})
test.serial('generates expected files', async () => {
helpers.mockPrompt(generator, {
moduleName: 'test',
description: 'test'
})
await pify(generator.run.bind(generator))()
assert.file([
'README.md'
])
})
test.serial('generates default file', async () => {
helpers.mockPrompt(generator, {
licensee: 'Richard McRichface'
})
await pify(generator.run.bind(generator))()
assert.fileContent('README.md', fs.readFileSync('../examples/default-readme.md').toString())
})
test.serial('generates different as given license', async () => {
helpers.mockPrompt(generator, {
licensee: 'Richard McRichface',
mit: false,
license: 'CC-BY-SA 3.0'
})
await pify(generator.run.bind(generator))()
assert.fileContent('README.md', fs.readFileSync('../examples/default-readme.md').toString())
})
test.serial('defaults to MIT license', async () => {
helpers.mockPrompt(generator, {
licensee: 'Richard McRichface',
mit: true,
license: 'CC-BY-SA 3.0'
})
await pify(generator.run.bind(generator))()
assert.fileContent('README.md', fs.readFileSync('../examples/different-license-readme.md').toString())
+})
test.serial('generates maximal file', async () => {
helpers.mockPrompt(generator, {
API: true,
background: true,
badge: true,
badges: true,
banner: true,
bannerPath: 'test',
contributeFile: true,
description: 'test',
license: 'test',
licensee: 'Richard McRichface',
longDescription: true,
maintainers: true,
mit: true,
moduleName: 'example',
prs: true,
security: true
})
await pify(generator.run.bind(generator))()
assert.fileContent('README.md', fs.readFileSync('../examples/maximal-readme.md').toString())
})