Skip to content

Commit

Permalink
Merge pull request #283 from vuejs/issue-282
Browse files Browse the repository at this point in the history
Gate typescript behind tsconfig check and added e2e test for project that doesn't use Typescript (Fix #282)
  • Loading branch information
JessicaSachs committed Sep 16, 2020
2 parents 98c5d81 + c0e8de1 commit 416c38e
Show file tree
Hide file tree
Showing 7 changed files with 4,250 additions and 1 deletion.
47 changes: 47 additions & 0 deletions e2e/__projects__/javascript/components/Basic.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<template>
<div class="hello">
<h1 :class="headingClasses">{{ msg }}</h1>
</div>
</template>

<style module="css">
.testA {
background-color: red;
}
</style>
<style module>
.testB {
background-color: blue;
}
</style>
<style>
.testC {
background-color: blue;
}
</style>

<script>
export default {
name: 'basic',
computed: {
headingClasses: function headingClasses() {
return {
red: this.isCrazy,
blue: !this.isCrazy,
shadow: this.isCrazy
}
}
},
data: function data() {
return {
msg: 'Welcome to Your Vue.js App',
isCrazy: false
}
},
methods: {
toggleClass: function toggleClass() {
this.isCrazy = !this.isCrazy
}
}
}
</script>
9 changes: 9 additions & 0 deletions e2e/__projects__/javascript/components/Coffee.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<h1>Coffee</h1>
</template>

<script lang="coffee">
export default
name: 'coffee'
data: -> {}
</script>
34 changes: 34 additions & 0 deletions e2e/__projects__/javascript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "javascript",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"private": true,
"scripts": {
"test": "jest --no-cache test.js"
},
"dependencies": {
"vue": "3.0.0-alpha.10"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.2.3",
"jest": "^24.0.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"vue"
],
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.vue$": "../../../lib/index.js"
}
},
"babel": {
"presets": [
"@babel/env"
]
}
}
29 changes: 29 additions & 0 deletions e2e/__projects__/javascript/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createApp, h } from 'vue'

import Basic from './components/Basic.vue'
import Coffee from './components/Coffee.vue'

function mount(Component, props, slots) {
document.getElementsByTagName('html')[0].innerHTML = ''
const el = document.createElement('div')
el.id = 'app'
document.body.appendChild(el)
const Parent = {
render() {
return h(Component, props, slots)
}
}
createApp(Parent).mount(el)
}

test('processes .vue files', () => {
mount(Basic)
expect(document.querySelector('h1').textContent).toBe(
'Welcome to Your Vue.js App'
)
})

test('processes .vue file with lang set to coffee', () => {
mount(Coffee)
expect(document.querySelector('h1').textContent).toBe('Coffee')
})

0 comments on commit 416c38e

Please sign in to comment.