@@ -92,6 +92,90 @@ test('properly handles v-model', async () => {
92
92
})
93
93
```
94
94
95
+ ## Example using ` props ` and [ ` stubs ` ] ( https://vue-test-utils.vuejs.org/api/options.html#stubs ) for thrid party compoents like ` bootstrap-vue ` :
96
+
97
+ ``` html
98
+ <template >
99
+ <b-row class =" mb-1" >
100
+ <b-col >
101
+ <label class =" form-label mb-md-1" >{{ label }}</label >
102
+
103
+ <b-form-input
104
+ type =" text"
105
+ list =" clist"
106
+ :disabled =" isDisabled"
107
+ :placeholder =" placeholder"
108
+ :value =" value"
109
+ @input =" $emit('input', $event)"
110
+ />
111
+
112
+ <datalist v-if =" isSearchable" id =" clist" >
113
+ <option
114
+ v-for =" (option, index) in searchOptions"
115
+ :key =" index"
116
+ :value =" option"
117
+ >
118
+ {{ option.suggestion }}
119
+ </option >
120
+ </datalist >
121
+ </b-col >
122
+ </b-row >
123
+ </template >
124
+
125
+ <script >
126
+ export default {
127
+ name: ' FormInput' ,
128
+ props: {
129
+ label: { type: String , default: ' Default label' },
130
+ value: { type: String , default: ' ' },
131
+ inputType: { type: String , default: ' text' },
132
+ placeholder: { type: String , default: ' Default placeholder' },
133
+ searchOptions: {
134
+ type: Array ,
135
+ default () {
136
+ return []
137
+ },
138
+ },
139
+ isSearchable: { type: Boolean , default: false },
140
+ },
141
+ }
142
+ </script >
143
+ ```
144
+
145
+ ``` js
146
+ import { render } from ' @testing-library/vue'
147
+ import { BRow , BCol , BFormInput } from ' bootstrap-vue'
148
+ import FormInput from ' ./FormInput.vue'
149
+ const stubs = {
150
+ // used to register custom or third-party components
151
+ ' b-form-input' : BFormInput,
152
+ ' b-row' : BRow,
153
+ ' b-col' : BCol,
154
+ }
155
+
156
+ it (' renders the correct default state' , () => {
157
+ const { getByText } = render (FormInput, {
158
+ stubs,
159
+ })
160
+
161
+ // Asserts initial state.
162
+ getByText (' Default label' )
163
+ })
164
+
165
+ it (' renders the label prop' , () => {
166
+ const props = {
167
+ label: ' The new label' ,
168
+ }
169
+ const { getByText } = render (FormInput, {
170
+ stubs,
171
+ props,
172
+ })
173
+
174
+ getByText (props .label )
175
+ })
176
+
177
+ ```
178
+
95
179
## More examples
96
180
97
181
You'll find examples of testing with different libraries in
0 commit comments