File tree 1 file changed +43
-1
lines changed
1 file changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -1827,6 +1827,49 @@ describe('directive',function(){
1827
1827
} ) ;
1828
1828
} ) ;
1829
1829
1830
+ it ( 'should handle onChange for array type' , function ( ) {
1831
+ inject ( function ( $compile , $rootScope ) {
1832
+ var scope = $rootScope . $new ( ) ;
1833
+ scope . obj = { } ;
1834
+
1835
+ scope . schema = {
1836
+ "type" : "object" ,
1837
+ "properties" : {
1838
+ "arr" : {
1839
+ "type" : "array" ,
1840
+ "items" : {
1841
+ "type" : "object" ,
1842
+ "properties" : {
1843
+ "name" : {
1844
+ "type" : "string" ,
1845
+ "default" : "Name"
1846
+ }
1847
+ }
1848
+ }
1849
+ }
1850
+ }
1851
+ } ;
1852
+
1853
+ scope . form = [ { key : "arr" , startEmpty : true , onChange : sinon . spy ( ) } ] ;
1854
+
1855
+ var tmpl = angular . element ( '<form sf-schema="schema" sf-form="form" sf-model="obj"></form>' ) ;
1856
+
1857
+ $compile ( tmpl ) ( scope ) ;
1858
+ $rootScope . $apply ( ) ;
1859
+
1860
+
1861
+ scope . form [ 0 ] . onChange . should . not . have . been . called ;
1862
+
1863
+
1864
+ tmpl . find ( 'button.btn-default' ) . click ( ) ;
1865
+ scope . form [ 0 ] . onChange . should . have . been . calledWith ( [ { name : "Name" } ] ) ;
1866
+
1867
+ tmpl . find ( 'button.close' ) . click ( ) ;
1868
+ scope . form [ 0 ] . onChange . should . have . been . calledWith ( [ ] ) ;
1869
+
1870
+ } ) ;
1871
+ } ) ;
1872
+
1830
1873
it ( 'should load template by templateUrl, with template field type' , function ( ) {
1831
1874
1832
1875
inject ( function ( $compile , $rootScope , $httpBackend ) {
@@ -2358,7 +2401,6 @@ describe('directive',function(){
2358
2401
} ) ;
2359
2402
} ) ;
2360
2403
2361
-
2362
2404
} ) ;
2363
2405
2364
2406
} ) ;
You can’t perform that action at this time.
0 commit comments