Skip to content

Commit 4d6bab2

Browse files
committed
Add test for escaping in package.json
1 parent f66bc1f commit 4d6bab2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/e2e/test.js

+32
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ function monkeyPatchInquirer (answers) {
3434
}
3535

3636
describe('vue-cli', () => {
37+
/* eslint-disable quotes */
38+
const escapedAuthor = "John \"The Tester\" Doe <[email protected]>"
39+
40+
const escapedAnswers = {
41+
name: 'vue-cli-test',
42+
author: 'John "The Tester" Doe <[email protected]>',
43+
description: 'vue-cli e2e test',
44+
preprocessor: {
45+
less: true,
46+
sass: true
47+
},
48+
pick: 'no',
49+
noEscape: true
50+
51+
}
52+
3753
const answers = {
3854
name: 'vue-cli-test',
3955
author: 'John Doe <[email protected]>',
@@ -106,6 +122,22 @@ describe('vue-cli', () => {
106122
})
107123
})
108124

125+
it('generate a vaild package.json with escaped author', done => {
126+
monkeyPatchInquirer(escapedAnswers)
127+
generate('test', MOCK_TEMPLATE_REPO_PATH, MOCK_TEMPLATE_BUILD_PATH, err => {
128+
if (err) done(err)
129+
130+
const pkg = fs.readFileSync(`${MOCK_TEMPLATE_BUILD_PATH}/package.json`, 'utf8')
131+
try {
132+
var validData = JSON.parse(pkg)
133+
expect(validData.author).to.equal(escapedAuthor)
134+
done()
135+
} catch (err) {
136+
done(err)
137+
}
138+
})
139+
})
140+
109141
it('avoid rendering files that do not have mustaches', done => {
110142
monkeyPatchInquirer(answers)
111143
const binFilePath = `${MOCK_TEMPLATE_REPO_PATH}/template/bin.file`

0 commit comments

Comments
 (0)