@@ -69,6 +69,7 @@ describe('ui-select tests', function() {
69
69
if ( attrs . theme !== undefined ) { attrsHtml += ' theme="' + attrs . theme + '"' ; }
70
70
if ( attrs . tabindex !== undefined ) { attrsHtml += ' tabindex="' + attrs . tabindex + '"' ; }
71
71
if ( attrs . tagging !== undefined ) { attrsHtml += ' tagging="' + attrs . tagging + '"' ; }
72
+ if ( attrs . taggingTokens !== undefined ) { attrsHtml += ' tagging-tokens="' + attrs . taggingTokens + '"' ; }
72
73
if ( attrs . title !== undefined ) { attrsHtml += ' title="' + attrs . title + '"' ; }
73
74
}
74
75
@@ -115,6 +116,17 @@ describe('ui-select tests', function() {
115
116
e . keyCode = keyCode ;
116
117
element . trigger ( e ) ;
117
118
}
119
+ function triggerPaste ( element , text ) {
120
+ var e = jQuery . Event ( "paste" ) ;
121
+ e . originalEvent = {
122
+ clipboardData : {
123
+ getData : function ( ) {
124
+ return text ;
125
+ }
126
+ }
127
+ } ;
128
+ element . trigger ( e ) ;
129
+ }
118
130
119
131
function setSearchText ( el , text ) {
120
132
el . scope ( ) . $select . search = text ;
@@ -1119,6 +1131,8 @@ describe('ui-select tests', function() {
1119
1131
if ( attrs . required !== undefined ) { attrsHtml += ' ng-required="' + attrs . required + '"' ; }
1120
1132
if ( attrs . tabindex !== undefined ) { attrsHtml += ' tabindex="' + attrs . tabindex + '"' ; }
1121
1133
if ( attrs . closeOnSelect !== undefined ) { attrsHtml += ' close-on-select="' + attrs . closeOnSelect + '"' ; }
1134
+ if ( attrs . tagging !== undefined ) { attrsHtml += ' tagging="' + attrs . tagging + '"' ; }
1135
+ if ( attrs . taggingTokens !== undefined ) { attrsHtml += ' tagging-tokens="' + attrs . taggingTokens + '"' ; }
1122
1136
}
1123
1137
1124
1138
return compileTemplate (
@@ -1611,6 +1625,40 @@ describe('ui-select tests', function() {
1611
1625
1612
1626
expect ( el . scope ( ) . $select . multiple ) . toBe ( true ) ;
1613
1627
} ) ;
1628
+
1629
+ it ( 'should allow paste tag from clipboard' , function ( ) {
1630
+ scope . taggingFunc = function ( name ) {
1631
+ return {
1632
+ name : name ,
1633
+ email : name + '@email.com' ,
1634
+ group : 'Foo' ,
1635
+ age : 12
1636
+ } ;
1637
+ } ;
1638
+
1639
+ var el = createUiSelectMultiple ( { tagging : 'taggingFunc' , taggingTokens : ",|ENTER" } ) ;
1640
+ clickMatch ( el ) ;
1641
+ triggerPaste ( el . find ( 'input' ) , 'tag1' ) ;
1642
+
1643
+ expect ( $ ( el ) . scope ( ) . $select . selected . length ) . toBe ( 1 ) ;
1644
+ } ) ;
1645
+
1646
+ it ( 'should allow paste multiple tags' , function ( ) {
1647
+ scope . taggingFunc = function ( name ) {
1648
+ return {
1649
+ name : name ,
1650
+ email : name + '@email.com' ,
1651
+ group : 'Foo' ,
1652
+ age : 12
1653
+ } ;
1654
+ } ;
1655
+
1656
+ var el = createUiSelectMultiple ( { tagging : 'taggingFunc' , taggingTokens : ",|ENTER" } ) ;
1657
+ clickMatch ( el ) ;
1658
+ triggerPaste ( el . find ( 'input' ) , ',tag1,tag2,tag3,,tag5,' ) ;
1659
+
1660
+ expect ( $ ( el ) . scope ( ) . $select . selected . length ) . toBe ( 5 ) ;
1661
+ } ) ;
1614
1662
} ) ;
1615
1663
1616
1664
describe ( 'default configuration via uiSelectConfig' , function ( ) {
0 commit comments