@@ -170,16 +170,37 @@ describe('TypeaheadTokenizer Component', function() {
170170 this . component . focus ( ) ;
171171 assert . equal ( this . component . refs . typeahead . focus . calledOnce , true ) ;
172172 } ) ;
173- } ) ;
174173
175- it ( 'should provide an exposed component function to get the selected tokens' , function ( ) {
176- simulateTokenInput ( this . component , 'o' ) ;
177- var entry = this . component . refs . typeahead . refs . entry ;
178- TestUtils . Simulate . keyDown ( entry , { keyCode : Keyevent . DOM_VK_DOWN } ) ;
179- TestUtils . Simulate . keyDown ( entry , { keyCode : Keyevent . DOM_VK_RETURN } ) ;
174+ it ( 'should provide an exposed component function to get the selected tokens' , function ( ) {
175+ simulateTokenInput ( this . component , 'o' ) ;
176+ var entry = this . component . refs . typeahead . refs . entry ;
177+ TestUtils . Simulate . keyDown ( entry , { keyCode : Keyevent . DOM_VK_DOWN } ) ;
178+ TestUtils . Simulate . keyDown ( entry , { keyCode : Keyevent . DOM_VK_RETURN } ) ;
179+
180+ assert . equal ( this . component . getSelectedTokens ( ) . length , 1 ) ;
181+ assert . equal ( this . component . getSelectedTokens ( ) [ 0 ] , "John" ) ;
182+ } ) ;
183+
184+ it ( 'should provide an exposed component function to add tokens' , function ( ) {
185+ this . component . addSelectedToken ( "John" )
186+ assert . equal ( this . component . getSelectedTokens ( ) . length , 1 ) ;
187+ assert . equal ( this . component . getSelectedTokens ( ) [ 0 ] , "John" ) ;
188+ } ) ;
189+
190+ it ( 'should provide an exposed component function to remove tokens' , function ( ) {
191+ this . component . addSelectedToken ( "John" )
192+ assert . equal ( this . component . getSelectedTokens ( ) . length , 1 ) ;
193+ this . component . removeSelectedToken ( "John" )
194+ assert . equal ( this . component . getSelectedTokens ( ) . length , 0 ) ;
195+ } ) ;
180196
181- assert . equal ( this . component . getSelectedTokens ( ) . length , 1 ) ;
182- assert . equal ( this . component . getSelectedTokens ( ) [ 0 ] , "John" ) ;
197+ it ( 'should provide an exposed component function to remove tokens' , function ( ) {
198+ this . component . addSelectedToken ( "John" )
199+ this . component . setSelectedTokens ( [ "Paul" , "George" ] )
200+ assert . equal ( this . component . getSelectedTokens ( ) . length , 2 ) ;
201+ assert . equal ( this . component . getSelectedTokens ( ) [ 0 ] , "Paul" ) ;
202+ assert . equal ( this . component . getSelectedTokens ( ) [ 1 ] , "George" ) ;
203+ } ) ;
183204 } ) ;
184205
185206 describe ( 'keyboard controls' , function ( ) {
0 commit comments