Skip to content

Commit

Permalink
Add test to support arrays in skipInterpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jan 1, 2017
1 parent 0d3f96d commit c117a83
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/e2e/mock-skip-glob/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"schema": {
"name": {
"type": "string",
"required": true,
"label": "Project name"
},
"description": {
"type": "string",
"required": true,
"label": "Project description",
"default": "A Vue.js project"
},
"author": {
"type": "string",
"label": "Author"
},
"private": {
"type": "boolean",
"default": true
}
},
"skipInterpolation": [
"src/**/*.{vue,js}",
"!src/**/yes.*"
]
}
13 changes: 13 additions & 0 deletions test/e2e/mock-skip-glob/template/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "{{ name }}",
"description": "{{ description }}",
"author": "{{ author }}",
"devDependencies": {
{{#preprocessor.less}}
"less": "^2.6.1",
{{/preprocessor.less}}
{{#preprocessor.sass}}
"node-sass": "^3.4.2"
{{/preprocessor.sass}}
}
}
1 change: 1 addition & 0 deletions test/e2e/mock-skip-glob/template/src/no.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('{{ no }}')
3 changes: 3 additions & 0 deletions test/e2e/mock-skip-glob/template/src/no.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<p>{{ no }}</p>
</template>
1 change: 1 addition & 0 deletions test/e2e/mock-skip-glob/template/src/yes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('yes.')
3 changes: 3 additions & 0 deletions test/e2e/mock-skip-glob/template/src/yes.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
\{{yes}} {{pick}}
</template>
26 changes: 26 additions & 0 deletions test/e2e/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const MOCK_META_JSON_PATH = './test/e2e/mock-meta-json'
const MOCK_TEMPLATE_REPO_PATH = './test/e2e/mock-template-repo'
const MOCK_TEMPLATE_BUILD_PATH = path.resolve('./test/e2e/mock-template-build')
const MOCK_METADATA_REPO_JS_PATH = './test/e2e/mock-metadata-repo-js'
const MOCK_SKIP_GLOB = './test/e2e/mock-skip-glob'

function monkeyPatchInquirer (answers) {
// monkey patch inquirer
Expand Down Expand Up @@ -155,6 +156,31 @@ describe('vue-cli', () => {
})
})

it('support multiple globs in skipInterpolation', done => {
monkeyPatchInquirer(answers)
const binFilePath = `${MOCK_SKIP_GLOB}/template/bin.file`
const wstream = fs.createWriteStream(binFilePath)
wstream.write(crypto.randomBytes(100))
wstream.end()

generate('test', MOCK_SKIP_GLOB, MOCK_TEMPLATE_BUILD_PATH, err => {
if (err) done(err)

const originalVueFileOne = fs.readFileSync(`${MOCK_SKIP_GLOB}/template/src/no.vue`, 'utf8')
const originalVueFileTwo = fs.readFileSync(`${MOCK_SKIP_GLOB}/template/src/no.js`, 'utf8')
const generatedVueFileOne = fs.readFileSync(`${MOCK_TEMPLATE_BUILD_PATH}/src/no.vue`, 'utf8')
const generatedVueFileTwo = fs.readFileSync(`${MOCK_TEMPLATE_BUILD_PATH}/src/no.js`, 'utf8')

expect(originalVueFileOne).to.equal(generatedVueFileOne)
expect(originalVueFileTwo).to.equal(generatedVueFileTwo)
expect(exists(binFilePath)).to.equal(true)
expect(exists(`${MOCK_TEMPLATE_BUILD_PATH}/bin.file`)).to.equal(true)
rm(binFilePath)

done()
})
})

it('validate input value', done => {
// deep copy
var invalidName = extend({}, answers, { name: 'INVALID-NAME' })
Expand Down

0 comments on commit c117a83

Please sign in to comment.