-
Notifications
You must be signed in to change notification settings - Fork 48
/
test.js
118 lines (95 loc) · 2.98 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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',
maintainers: 'RichardLitt'
})
await pify(generator.run.bind(generator))()
assert.file([
'README.md'
])
})
test.serial('generates default file', async () => {
helpers.mockPrompt(generator, {
licensee: 'Richard McRichface',
maintainers: 'RichardLitt'
})
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, {
maintainers: 'RichardLitt',
licensee: 'Richard McRichface',
mit: false,
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('defaults to MIT license', async () => {
helpers.mockPrompt(generator, {
maintainers: 'RichardLitt',
licensee: 'Richard McRichface',
mit: true,
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('generates different year if given', async () => {
helpers.mockPrompt(generator, {
maintainers: 'RichardLitt',
licensee: 'Richard McRichface',
mit: true,
year: false,
diffYear: 2016
})
await pify(generator.run.bind(generator))()
assert.fileContent('README.md', fs.readFileSync('../examples/different-year.md').toString())
})
test.serial('does not generate different year if present year is confirmed', async () => {
helpers.mockPrompt(generator, {
maintainers: 'RichardLitt',
licensee: 'Richard McRichface',
mit: true,
year: true,
diffYear: 2016
})
await pify(generator.run.bind(generator))()
assert.fileContent('README.md', fs.readFileSync('../examples/default-readme.md').toString())
})
test.serial('generates maximal file', async () => {
helpers.mockPrompt(generator, {
API: true,
background: true,
badge: true,
badges: true,
banner: true,
bannerPath: 'test',
contributingFile: true,
description: 'test',
license: 'test',
licensee: 'Richard McRichface',
longDescription: true,
maintainers: 'RichardLitt',
mit: true,
moduleName: 'example',
prs: true,
security: true,
year: true
})
await pify(generator.run.bind(generator))()
assert.fileContent('README.md', fs.readFileSync('../examples/maximal-readme.md').toString())
})