Skip to content

Commit c117a83

Browse files
committed
Add test to support arrays in skipInterpolation
1 parent 0d3f96d commit c117a83

File tree

7 files changed

+74
-0
lines changed

7 files changed

+74
-0
lines changed

test/e2e/mock-skip-glob/meta.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"schema": {
3+
"name": {
4+
"type": "string",
5+
"required": true,
6+
"label": "Project name"
7+
},
8+
"description": {
9+
"type": "string",
10+
"required": true,
11+
"label": "Project description",
12+
"default": "A Vue.js project"
13+
},
14+
"author": {
15+
"type": "string",
16+
"label": "Author"
17+
},
18+
"private": {
19+
"type": "boolean",
20+
"default": true
21+
}
22+
},
23+
"skipInterpolation": [
24+
"src/**/*.{vue,js}",
25+
"!src/**/yes.*"
26+
]
27+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "{{ name }}",
3+
"description": "{{ description }}",
4+
"author": "{{ author }}",
5+
"devDependencies": {
6+
{{#preprocessor.less}}
7+
"less": "^2.6.1",
8+
{{/preprocessor.less}}
9+
{{#preprocessor.sass}}
10+
"node-sass": "^3.4.2"
11+
{{/preprocessor.sass}}
12+
}
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('{{ no }}')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<p>{{ no }}</p>
3+
</template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('yes.')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
\{{yes}} {{pick}}
3+
</template>

test/e2e/test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const MOCK_META_JSON_PATH = './test/e2e/mock-meta-json'
1515
const MOCK_TEMPLATE_REPO_PATH = './test/e2e/mock-template-repo'
1616
const MOCK_TEMPLATE_BUILD_PATH = path.resolve('./test/e2e/mock-template-build')
1717
const MOCK_METADATA_REPO_JS_PATH = './test/e2e/mock-metadata-repo-js'
18+
const MOCK_SKIP_GLOB = './test/e2e/mock-skip-glob'
1819

1920
function monkeyPatchInquirer (answers) {
2021
// monkey patch inquirer
@@ -155,6 +156,31 @@ describe('vue-cli', () => {
155156
})
156157
})
157158

159+
it('support multiple globs in skipInterpolation', done => {
160+
monkeyPatchInquirer(answers)
161+
const binFilePath = `${MOCK_SKIP_GLOB}/template/bin.file`
162+
const wstream = fs.createWriteStream(binFilePath)
163+
wstream.write(crypto.randomBytes(100))
164+
wstream.end()
165+
166+
generate('test', MOCK_SKIP_GLOB, MOCK_TEMPLATE_BUILD_PATH, err => {
167+
if (err) done(err)
168+
169+
const originalVueFileOne = fs.readFileSync(`${MOCK_SKIP_GLOB}/template/src/no.vue`, 'utf8')
170+
const originalVueFileTwo = fs.readFileSync(`${MOCK_SKIP_GLOB}/template/src/no.js`, 'utf8')
171+
const generatedVueFileOne = fs.readFileSync(`${MOCK_TEMPLATE_BUILD_PATH}/src/no.vue`, 'utf8')
172+
const generatedVueFileTwo = fs.readFileSync(`${MOCK_TEMPLATE_BUILD_PATH}/src/no.js`, 'utf8')
173+
174+
expect(originalVueFileOne).to.equal(generatedVueFileOne)
175+
expect(originalVueFileTwo).to.equal(generatedVueFileTwo)
176+
expect(exists(binFilePath)).to.equal(true)
177+
expect(exists(`${MOCK_TEMPLATE_BUILD_PATH}/bin.file`)).to.equal(true)
178+
rm(binFilePath)
179+
180+
done()
181+
})
182+
})
183+
158184
it('validate input value', done => {
159185
// deep copy
160186
var invalidName = extend({}, answers, { name: 'INVALID-NAME' })

0 commit comments

Comments
 (0)