@@ -232,6 +232,9 @@ describe("draggable.vue when initialized with list", () => {
232
232
on : {
233
233
input
234
234
} ,
235
+ attrs : {
236
+ attribute1 : "value1"
237
+ } ,
235
238
props : {
236
239
prop1 : "info" ,
237
240
prop2 : true
@@ -254,12 +257,18 @@ describe("draggable.vue when initialized with list", () => {
254
257
expect ( fakeChild . props ( "prop1" ) ) . toEqual ( "info" ) ;
255
258
} )
256
259
257
- it ( "pass data to tag child" , async ( ) => {
260
+ it ( "pass event listener to tag child" , async ( ) => {
258
261
const child = wrapper . find ( Fake ) ;
259
262
const evt = { data : 33 } ;
260
263
child . vm . $emit ( 'input' , evt ) ;
261
264
expect ( input ) . toHaveBeenCalledWith ( evt ) ;
262
265
} )
266
+
267
+ it ( "pass attributes to tag child" , async ( ) => {
268
+ const child = wrapper . find ( Fake ) ;
269
+ const attrValue = child . attributes ( "attribute1" ) ;
270
+ expect ( attrValue ) . toEqual ( "value1" ) ;
271
+ } )
263
272
} ) ;
264
273
265
274
it ( "keeps a reference to Sortable instance" , ( ) => {
@@ -521,8 +530,8 @@ describe("draggable.vue when initialized with list", () => {
521
530
} )
522
531
523
532
describe . each ( [
524
- [ 1 , [ "b" , "a" , "c" ] ] ,
525
- [ 3 , [ "a" , "c" , "b" ] ]
533
+ [ 1 , [ "b" , "a" , "c" ] ] ,
534
+ [ 3 , [ "a" , "c" , "b" ] ]
526
535
] )
527
536
( "when update is called with new index being %i" ,
528
537
( index , expectedList ) => {
@@ -562,7 +571,7 @@ describe("draggable.vue when initialized with list", () => {
562
571
563
572
it ( "sends a change event" , async ( ) => {
564
573
await Vue . nextTick ( ) ;
565
- const expectedEvt = { moved : { element : "b" , oldIndex : 1 , newIndex : index - 1 } } ;
574
+ const expectedEvt = { moved : { element : "b" , oldIndex : 1 , newIndex : index - 1 } } ;
566
575
expect ( wrapper . emitted ( ) . change ) . toEqual ( [ [ expectedEvt ] ] ) ;
567
576
} )
568
577
} ) ;
@@ -795,23 +804,23 @@ describe("draggable.vue when initialized with list", () => {
795
804
[ "data-valor2" , "bd" ] ,
796
805
[ "data-attribute" , "efg" ]
797
806
] ) (
798
- "renders attribute %s with value %s as html attribute" ,
807
+ "renders attribute %s with value %s as html attribute" ,
799
808
( attribute , value ) => {
800
- wrapper = shallowMount ( draggable , {
801
- propsData : {
802
- list : [ ]
803
- } ,
804
- attrs : {
805
- [ attribute ] : value ,
806
- } ,
807
- slots : {
808
- default : "" ,
809
- }
809
+ wrapper = shallowMount ( draggable , {
810
+ propsData : {
811
+ list : [ ]
812
+ } ,
813
+ attrs : {
814
+ [ attribute ] : value ,
815
+ } ,
816
+ slots : {
817
+ default : "" ,
818
+ }
819
+ } ) ;
820
+ const element = wrapper . find ( `[${ attribute } ='${ value } ']` ) ;
821
+ expect ( element . is ( "div" ) ) . toBe ( true ) ;
822
+ expect ( element . html ( ) ) . toEqual ( wrapper . html ( ) ) ;
810
823
} ) ;
811
- const element = wrapper . find ( `[${ attribute } ='${ value } ']` ) ;
812
- expect ( element . is ( "div" ) ) . toBe ( true ) ;
813
- expect ( element . html ( ) ) . toEqual ( wrapper . html ( ) ) ;
814
- } ) ;
815
824
} )
816
825
817
826
describe ( "draggable.vue when initialized with value" , ( ) => {
0 commit comments