@@ -54,7 +54,7 @@ describe('uiMentionController', () => {
5454
5555 beforeEach ( function ( ) {
5656 $scope . model = 'bar' ;
57- $element = angular . element ( '<span ui-mention ng-model="model"></span>' ) ;
57+ $element = angular . element ( '<span ui-mention ng-model="model"></span><span></span> ' ) ;
5858 ctrlInstance = createController ( $element ) ;
5959 $scope . $digest ( ) ;
6060 } ) ;
@@ -107,6 +107,11 @@ describe('uiMentionController', () => {
107107 mentionParser ( 'foo bar' ) ;
108108 expect ( ctrlInstance . mentions ) . to . eql ( mentions . slice ( 0 , 1 ) ) ;
109109 } ) ;
110+
111+ it ( 'updates the HTML content of the adjacent DOM element' , ( ) => {
112+ mentionParser ( 'foo bar' ) ;
113+ expect ( $element . next ( ) . html ( ) ) . to . eq ( '<span>foo bar</span>' ) ;
114+ } ) ;
110115 } ) ;
111116
112117 context ( 'ngModel.$formatters' , ( ) => {
@@ -155,6 +160,12 @@ describe('uiMentionController', () => {
155160 ngModel . $render ( ) ;
156161 expect ( $element . val ( ) ) . to . eq ( '' ) ;
157162 } ) ;
163+
164+ it ( 'updates the HTML content of the adjacent DOM element' , ( ) => {
165+ ngModel . $modelValue = '@[foo bar:1]' ;
166+ ngModel . $render ( ) ;
167+ expect ( $element . next ( ) . html ( ) ) . to . eq ( '<span>foo bar</span>' ) ;
168+ } ) ;
158169 } ) ;
159170 } ) ;
160171
@@ -216,7 +227,7 @@ describe('uiMentionController', () => {
216227 } ) ;
217228
218229 context ( '.label()' , ( ) => {
219- it ( 'convets the given object to a readable string' , ( ) => {
230+ it ( 'converts the given object to a readable string' , ( ) => {
220231 expect ( ctrlInstance . label ( { first : 0 , last : 1 } ) ) . to . eq ( '0 1' ) ;
221232 } ) ;
222233 } ) ;
@@ -248,6 +259,16 @@ describe('uiMentionController', () => {
248259 expect ( ctrlInstance . mentions [ 0 ] ) . to . eql ( { first : 'foo' , last : 'bar' } ) ;
249260 } ) ;
250261
262+ it ( 'clears the controller choices' , ( ) => {
263+ ctrlInstance . select ( { first : 'foo' , last : 'bar' } ) ;
264+ expect ( ctrlInstance . choices ) . to . eql ( [ ] ) ;
265+ } ) ;
266+
267+ it ( 'sets the searching regex to null' , ( ) => {
268+ ctrlInstance . select ( { first : 'foo' , last : 'bar' } ) ;
269+ expect ( ctrlInstance . searching ) . to . eq ( null ) ;
270+ } ) ;
271+
251272 it ( 'returns nothing' , ( ) => {
252273 expect ( ctrlInstance . select ( { first : 'foo' , last : 'bar' } ) ) . to . eq ( undefined ) ;
253274 } ) ;
0 commit comments