Skip to content

Instantly share code, notes, and snippets.

View visualjerk's full-sized avatar
🤔
Curious

Jörg Bayreuther visualjerk

🤔
Curious
View GitHub Profile
var disableBodyScroll = (function () {
/**
* Private variables
*/
var _selector = false,
_element = false,
_clientY;
/**
* Polyfills for Element.matches and Element.closest
<template>
<transition
@enter="enter"
@after-enter="afterEnter"
@leave="leave"
@after-leave="afterLeave"
>
<slot />
</transition>
</template>
import { mount, config } from '@vue/test-utils'
import MyTransition from './my-transition.vue'
import AwaitPromises from 'await-promises'
// Use default vue transition comp
config.stubs.transition = false
describe('MyTransition.vue', () => {
it('cleans styles after enter transition', async () => {
// Initialize waiter
import { mount, config } from '@vue/test-utils'
import MyTransition from './my-transition.vue'
// Use default vue transition comp
config.stubs.transition = false
describe('MyTransition.vue', () => {
it('cleans styles after enter transition', () => {
const comp = {
template: `<div><my-transition><p v-show="show">foo</p></my-transition></div>`,
describe('MyTransition.vue', () => {
// Make this test async
it('cleans styles after enter transition', async () => {
...
// Wait for async stuff to finish
await asyncStuff()
expect(foo.element.style.cssText).toEqual('')
})
})
@visualjerk
visualjerk / LoginForm.vue
Last active March 26, 2021 09:31
Testing Vue 3 Components - LoginForm.vue
<script>
export default {
name: 'LoginForm',
emits: ['submit'],
data() {
return {
formData: {
username: '',
password: '',
},
@visualjerk
visualjerk / LoginForm.spec.js
Last active March 26, 2021 08:52
Testing Vue 3 Components - LoginForm.spec.js
import { mount } from '@vue/test-utils'
import LoginForm from './LoginForm.vue'
describe('LoginForm', () => {
it('does not submit empty form', () => {
const wrapper = mount(LoginForm)
const form = wrapper.find('form')
form.trigger('submit')
expect(wrapper.emitted('submit')).toBeUndefined()
})