@@ -69,7 +69,7 @@ describe("draggable.vue when initialized with list", () => {
69
69
element = wrapper . element ;
70
70
} ) ;
71
71
72
- describe ( "when initialized with incorrect props " , ( ) => {
72
+ describe ( "in case of misuse " , ( ) => {
73
73
const { error } = console ;
74
74
const { warn } = console ;
75
75
@@ -83,15 +83,15 @@ describe("draggable.vue when initialized with list", () => {
83
83
console . warn = warn ;
84
84
} ) ;
85
85
86
- it ( "log an error when list and value are both not null" , ( ) => {
86
+ it ( "logs an error when list and value are both not null when initialized with incorrect props " , ( ) => {
87
87
wrapper = mount ( draggable , {
88
88
props : {
89
89
list : [ ] ,
90
90
modelValue : [ ] ,
91
91
itemKey : k => k
92
92
} ,
93
93
slots : {
94
- item : ( { element} ) => h ( "div" , null , element )
94
+ item : ( { element } ) => h ( "div" , null , element )
95
95
}
96
96
} ) ;
97
97
expect ( console . error ) . toBeCalledWith (
@@ -112,7 +112,27 @@ describe("draggable.vue when initialized with list", () => {
112
112
expect ( wrapper . html ( ) ) . toContain (
113
113
"Error: draggable element must have an item slot"
114
114
) ;
115
- } )
115
+ } ) ;
116
+
117
+ it ( "renders an error when item slot render multiple nodes" , ( ) => {
118
+ wrapper = mount ( draggable , {
119
+ props : {
120
+ list : [ 1 ] ,
121
+ modelValue : [ ] ,
122
+ itemKey : k => k
123
+ } ,
124
+ slots : {
125
+ item : ( { element, index } ) => {
126
+ return [ h ( "div" , null , element ) , h ( "span" , null , index ) ] ;
127
+ }
128
+ }
129
+ } ) ;
130
+
131
+ expect ( wrapper . element . nodeName ) . toEqual ( "PRE" ) ;
132
+ expect ( wrapper . html ( ) ) . toContain (
133
+ "Error: Item slot must have only one child"
134
+ ) ;
135
+ } ) ;
116
136
} ) ;
117
137
118
138
it ( "instantiate without error" , ( ) => {
0 commit comments