@@ -136,6 +136,8 @@ describe('uiAce', function () {
136136 . createSpy ( 'window.ace.edit' )
137137 . and . callFake ( function ( ) {
138138 _ace = aceEditFunction . apply ( this , arguments ) ;
139+ _ace . setReadOnly = jasmine . createSpy ( 'ace.setReadOnly' )
140+ . and . callThrough ( ) ;
139141 return _ace ;
140142 } ) ;
141143 } ) ;
@@ -177,27 +179,40 @@ describe('uiAce', function () {
177179 } ) ;
178180
179181 describe ( 'readOnly' , function ( ) {
182+
180183 it ( 'should read only option true' , function ( ) {
181- $compile ( '<div ui-ace readonly="true">' ) ( scope ) ;
184+ $compile ( '<div ui-ace readonly>' ) ( scope ) ;
185+ scope . $apply ( ) ;
186+ expect ( _ace . setReadOnly ) . toHaveBeenCalledWith ( true ) ;
187+
188+ $compile ( '<div ui-ace ng-readonly="true">' ) ( scope ) ;
182189 scope . $apply ( ) ;
183- expect ( _ace . getReadOnly ( ) ) . toBeTruthy ( ) ;
184- $compile ( '<div ui-ace readonly="{{foo}}">' ) ( scope ) ;
190+ expect ( _ace . setReadOnly ) . toHaveBeenCalledWith ( true ) ;
191+
192+ $compile ( '<div ui-ace ng-readonly="foo">' ) ( scope ) ;
185193 scope . $apply ( 'foo = true' ) ;
186- expect ( _ace . getReadOnly ( ) ) . toBeTruthy ( ) ;
194+ expect ( _ace . setReadOnly ) . toHaveBeenCalledWith ( true ) ;
195+
187196 } ) ;
197+
188198 it ( 'should read only option false' , function ( ) {
189199 $compile ( '<div ui-ace>' ) ( scope ) ;
190200 scope . $apply ( ) ;
191- expect ( _ace . getReadOnly ( ) ) . toBeFalsy ( ) ;
192- $compile ( '<div ui-ace readonly="false">' ) ( scope ) ;
201+ expect ( _ace . setReadOnly ) . not . toHaveBeenCalled ( ) ;
202+
203+ $compile ( '<div ui-ace ng-readonly="false">' ) ( scope ) ;
193204 scope . $apply ( ) ;
194- expect ( _ace . getReadOnly ( ) ) . toBeFalsy ( ) ;
195- $compile ( '<div ui-ace readonly="{{foo}}">' ) ( scope ) ;
196- expect ( _ace . getReadOnly ( ) ) . toBeFalsy ( ) ;
197- scope . $apply ( 'foo = true' ) ;
198- expect ( _ace . getReadOnly ( ) ) . toBeTruthy ( ) ;
205+ expect ( _ace . setReadOnly ) . toHaveBeenCalledWith ( false ) ;
206+
207+ $compile ( '<div ui-ace ng-readonly="foo">' ) ( scope ) ;
208+ scope . $apply ( ) ;
209+ expect ( _ace . setReadOnly ) . toHaveBeenCalledWith ( false ) ;
210+
211+ scope . $apply ( 'foo = null' ) ;
212+ expect ( _ace . setReadOnly ) . toHaveBeenCalledWith ( false ) ;
213+
199214 scope . $apply ( 'foo = false' ) ;
200- expect ( _ace . getReadOnly ( ) ) . toBeFalsy ( ) ;
215+ expect ( _ace . setReadOnly ) . toHaveBeenCalledWith ( false ) ;
201216 } ) ;
202217 } ) ;
203218
0 commit comments