-
Notifications
You must be signed in to change notification settings - Fork 112
add simple directive and test #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<input v-value="value" /> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
value: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped></style> | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function value(el, binding) { | ||
el.value = binding.value | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import '@testing-library/jest-dom/extend-expect' | ||
import {render, wait} from '@testing-library/vue' | ||
import {value as valueDirective} from './components/directives/v-value' | ||
import CompWithDirective from './components/CompWithDirective.vue' | ||
|
||
test('element should have the same value as the directive', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel the example is a bit "wordy" (it says I think it would be best if we used a simpler example with a clearer directive. Also I'd love to avoid using What do you think about that? |
||
const value = 'test' | ||
const {container, updateProps} = render( | ||
CompWithDirective, | ||
{props: {value}}, | ||
vue => vue.directive('value', valueDirective), | ||
) | ||
await wait() | ||
expect(container.firstChild).toHaveValue(value) | ||
const anotherValue = 'another' | ||
await updateProps({value: anotherValue}) | ||
expect(container.firstChild).toHaveValue(anotherValue) | ||
}) |
Uh oh!
There was an error while loading. Please reload this page.