@@ -69,6 +69,7 @@ describe('ui-select tests', function() {
6969 if ( attrs . theme !== undefined ) { attrsHtml += ' theme="' + attrs . theme + '"' ; }
7070 if ( attrs . tabindex !== undefined ) { attrsHtml += ' tabindex="' + attrs . tabindex + '"' ; }
7171 if ( attrs . tagging !== undefined ) { attrsHtml += ' tagging="' + attrs . tagging + '"' ; }
72+ if ( attrs . taggingTokens !== undefined ) { attrsHtml += ' tagging-tokens="' + attrs . taggingTokens + '"' ; }
7273 if ( attrs . title !== undefined ) { attrsHtml += ' title="' + attrs . title + '"' ; }
7374 }
7475
@@ -115,6 +116,17 @@ describe('ui-select tests', function() {
115116 e . keyCode = keyCode ;
116117 element . trigger ( e ) ;
117118 }
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+ }
118130
119131 function setSearchText ( el , text ) {
120132 el . scope ( ) . $select . search = text ;
@@ -1119,6 +1131,8 @@ describe('ui-select tests', function() {
11191131 if ( attrs . required !== undefined ) { attrsHtml += ' ng-required="' + attrs . required + '"' ; }
11201132 if ( attrs . tabindex !== undefined ) { attrsHtml += ' tabindex="' + attrs . tabindex + '"' ; }
11211133 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 + '"' ; }
11221136 }
11231137
11241138 return compileTemplate (
@@ -1611,6 +1625,40 @@ describe('ui-select tests', function() {
16111625
16121626 expect ( el . scope ( ) . $select . multiple ) . toBe ( true ) ;
16131627 } ) ;
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+ } ) ;
16141662 } ) ;
16151663
16161664 describe ( 'default configuration via uiSelectConfig' , function ( ) {
0 commit comments