Skip to content

Commit

Permalink
Add test for escaping in package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
riesinger committed Mar 9, 2017
1 parent f66bc1f commit 4d6bab2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/e2e/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ function monkeyPatchInquirer (answers) {
}

describe('vue-cli', () => {
/* eslint-disable quotes */
const escapedAuthor = "John \"The Tester\" Doe <john@doe.com>"

const escapedAnswers = {
name: 'vue-cli-test',
author: 'John "The Tester" Doe <john@doe.com>',
description: 'vue-cli e2e test',
preprocessor: {
less: true,
sass: true
},
pick: 'no',
noEscape: true

}

const answers = {
name: 'vue-cli-test',
author: 'John Doe <john@doe.com>',
Expand Down Expand Up @@ -106,6 +122,22 @@ describe('vue-cli', () => {
})
})

it('generate a vaild package.json with escaped author', done => {
monkeyPatchInquirer(escapedAnswers)
generate('test', MOCK_TEMPLATE_REPO_PATH, MOCK_TEMPLATE_BUILD_PATH, err => {
if (err) done(err)

const pkg = fs.readFileSync(`${MOCK_TEMPLATE_BUILD_PATH}/package.json`, 'utf8')
try {
var validData = JSON.parse(pkg)
expect(validData.author).to.equal(escapedAuthor)
done()
} catch (err) {
done(err)
}
})
})

it('avoid rendering files that do not have mustaches', done => {
monkeyPatchInquirer(answers)
const binFilePath = `${MOCK_TEMPLATE_REPO_PATH}/template/bin.file`
Expand Down

0 comments on commit 4d6bab2

Please sign in to comment.