File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -87,20 +87,20 @@ angular.scenario.dsl('using', function() {
8787 */
8888angular . scenario . dsl ( 'binding' , function ( ) {
8989 function contains ( text , value ) {
90- return text && text . indexOf ( value ) >= 0 ;
90+ return text && text . indexOf ( value ) >= 0 ;
9191 }
9292 return function ( name ) {
9393 return this . addFutureAction ( "select binding '" + name + "'" , function ( $window , $document , done ) {
9494 var elements = $document . elements ( '.ng-binding' ) ;
9595 for ( var i = 0 ; i < elements . length ; i ++ ) {
9696 var element = new elements . init ( elements [ i ] ) ;
97- if ( contains ( element . attr ( 'ng:bind' ) , name ) >= 0 ||
98- contains ( element . attr ( 'ng:bind-template' ) , name ) >= 0 ) {
97+ if ( contains ( element . attr ( 'ng:bind' ) , name ) ||
98+ contains ( element . attr ( 'ng:bind-template' ) , name ) ) {
9999 done ( null , element . text ( ) ) ;
100100 return ;
101101 }
102102 }
103- throw "Could not find binding: " + name ;
103+ done ( 'Binding selector ' + name + ' did not match.' ) ;
104104 } ) ;
105105 } ;
106106} ) ;
Original file line number Diff line number Diff line change @@ -271,7 +271,19 @@ describe("angular.scenario.dsl", function() {
271271 expect ( $root . futureResult ) . toEqual ( 'foo some baz' ) ;
272272 } ) ;
273273
274- it ( 'should return error if no binding exists' , function ( ) {
274+ it ( 'should match bindings by substring match' , function ( ) {
275+ doc . append ( '<pre class="ng-binding" ng:bind="foo.bar() && test.baz() | filter">binding value</pre>' ) ;
276+ $root . dsl . binding ( 'test.baz' ) ;
277+ expect ( $root . futureResult ) . toEqual ( 'binding value' ) ;
278+ } ) ;
279+
280+ it ( 'should return error if no bindings in document' , function ( ) {
281+ $root . dsl . binding ( 'foo.bar' ) ;
282+ expect ( $root . futureError ) . toMatch ( / d i d n o t m a t c h / ) ;
283+ } ) ;
284+
285+ it ( 'should return error if no binding matches' , function ( ) {
286+ doc . append ( '<span class="ng-binding" ng:bind="foo">some value</span>' ) ;
275287 $root . dsl . binding ( 'foo.bar' ) ;
276288 expect ( $root . futureError ) . toMatch ( / d i d n o t m a t c h / ) ;
277289 } ) ;
You can’t perform that action at this time.
0 commit comments