Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiller1990 committed Sep 20, 2020
1 parent 6885dbb commit 7a44efd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 15 deletions.
20 changes: 16 additions & 4 deletions tests/Hello.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
<button @click="inc">Count: {{ count }}</button>
</template>

<script setup="props, { emit }" lang="ts">
import { ref } from 'vue'
<script lang="ts">
import {
defineComponent,
ref
} from 'vue'
export const count = ref<string>(5)
export const inc = () => count.value++
export default defineComponent({
setup() {
const count = ref<string>(5)
const inc = () => count.value++
return {
count,
inc
}
}
})
</script>
10 changes: 10 additions & 0 deletions tests/ScriptSetup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<button @click="increase">Count: {{ num }}</button>
</template>

<script setup="props, { emit }" lang="ts">
import { ref } from 'vue'
export const num = ref<string>(5)
export const increase = () => num.value++
</script>
38 changes: 27 additions & 11 deletions tests/e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createApp } from 'vue'
import ScriptSetup from './ScriptSetup.vue'
import Hello from './Hello.vue'
import KitchenSink from './KitchenSink.vue'
// import KitchenSink from './KitchenSink.vue'

function mount(comp: any, props: any = {}) {
document.getElementsByTagName('html')[0].innerHTML = ''
Expand All @@ -9,14 +10,29 @@ function mount(comp: any, props: any = {}) {
createApp(comp, props).mount(el)
}

test('works on a basic component', () => {
mount(Hello)
expect(document.body.outerHTML).toContain('Count: 5')
})
describe('E2E', () => {
it('works - 1', () => {
expect(1).toBe(1)
})

it('works with script setup component', () => {
mount(ScriptSetup)
expect(document.body.outerHTML).toContain('Count: 5')
})

it('works on a basic component', () => {
mount(Hello)
expect(document.body.outerHTML).toContain('Count: 5')
})

xtest('works on a complex component', () => {
mount(KitchenSink, { msg: 'hello world' })
expect(document.body.outerHTML).toContain('Count: 5')
expect(document.body.outerHTML).toContain('hello world')
console.log(document.body.outerHTML)
})
it('works - 2', () => {
expect(1).toBe(1)
})

// xit('works on a complex component', () => {
// mount(KitchenSink, { msg: 'hello world' })
// expect(document.body.outerHTML).toContain('Count: 5')
// expect(document.body.outerHTML).toContain('hello world')
// console.log(document.body.outerHTML)
// })
})

0 comments on commit 7a44efd

Please sign in to comment.