Created
June 1, 2019 19:39
-
-
Save visualjerk/89368a003dedd6925f5dfed803013883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
const waiter = new AwaitPromises | |
// Start collecting promises | |
waiter.collect() | |
const comp = { | |
template: `<div><my-transition><p v-show="show">foo</p></my-transition></div>`, | |
components: { | |
MyTransition | |
}, | |
data() { | |
return { | |
show: false | |
} | |
} | |
} | |
const wrapper = mount(comp) | |
// This triggers asynchronous behaviour inside the comp | |
wrapper.vm.show = true | |
const foo = wrapper.find('p') | |
// Stop collecting promises | |
waiter.stop() | |
// Wait until all promises have finished | |
await waiter.wait() | |
expect(foo.element.style.cssText).toEqual('') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment