File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
questions/218-h-render-function Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import { mount } from "@vue/test-utils"
2+ import { describe , it , expect } from "vitest"
3+
4+ import MyButton from "./MyButton"
5+
6+ describe ( "Render function h()" , ( ) => {
7+ it ( "renders a 'MyButton'" , ( ) => {
8+ const wrapper = mount ( MyButton )
9+ expect ( wrapper . element . tagName . toLocaleLowerCase ( ) ) . toBe ( 'button' )
10+ } )
11+
12+ it ( "disabled" , async ( ) => {
13+ const wrapper = mount ( MyButton , {
14+ props : {
15+ disabled : true
16+ }
17+ } )
18+ expect ( wrapper . find ( 'button' ) . attributes ( ) ) . toBeDefined ( )
19+
20+ await wrapper . trigger ( 'click' )
21+ expect ( wrapper . emitted ( 'click' ) ) . toBeUndefined ( )
22+ } )
23+
24+ it ( "slot" , ( ) => {
25+ const wrapper = mount ( MyButton , {
26+ slots : {
27+ default : 'my button'
28+ }
29+ } )
30+ expect ( wrapper . text ( ) ) . toBe ( 'my button' )
31+ } )
32+
33+ it ( 'custom click defined' , ( ) => {
34+ const wrapper = mount ( MyButton )
35+ wrapper . trigger ( 'click' )
36+ expect ( wrapper . emitted ( ) . customClick || wrapper . emitted ( ) [ 'custom-click' ] ) . toBeDefined ( )
37+ } )
38+ } )
You can’t perform that action at this time.
0 commit comments