@@ -1273,6 +1273,11 @@ describe('FormsManager', () => {
1273
1273
} ) ,
1274
1274
} ) ;
1275
1275
1276
+ const addressForm = new FormGroup ( {
1277
+ zip : new FormControl ( '12345' ) ,
1278
+ place : new FormControl ( 'Schenectady' ) ,
1279
+ } ) ;
1280
+
1276
1281
it ( 'should get and set initial Value for a control' , ( ) => {
1277
1282
formsManager . setInitialValue ( 'config' , 'initial' ) ;
1278
1283
@@ -1306,6 +1311,26 @@ describe('FormsManager', () => {
1306
1311
it ( 'should get undefined if no initial Value set' , ( ) => {
1307
1312
expect ( formsManager . getInitialValue ( 'other' ) ) . toBeUndefined ( ) ;
1308
1313
} ) ;
1314
+
1315
+ it ( 'should clear initial Value for a group of control' , ( ) => {
1316
+ formsManager . upsert ( 'user' , userForm , { withInitialValue : true } ) ;
1317
+ formsManager . upsert ( 'address' , addressForm , { withInitialValue : true } ) ;
1318
+
1319
+ formsManager . clear ( 'user' ) ;
1320
+
1321
+ expect ( formsManager . getInitialValue ( 'user' ) ) . toBeUndefined ( ) ;
1322
+ expect ( formsManager . getInitialValue ( 'address' ) ) . toBeDefined ( ) ;
1323
+ } ) ;
1324
+
1325
+ it ( 'should clear all initial Values when clearing full store' , ( ) => {
1326
+ formsManager . upsert ( 'user' , userForm , { withInitialValue : true } ) ;
1327
+ formsManager . upsert ( 'address' , addressForm , { withInitialValue : true } ) ;
1328
+
1329
+ formsManager . clear ( ) ;
1330
+
1331
+ expect ( formsManager . getInitialValue ( 'user' ) ) . toBeUndefined ( ) ;
1332
+ expect ( formsManager . getInitialValue ( 'address' ) ) . toBeUndefined ( ) ;
1333
+ } ) ;
1309
1334
} ) ;
1310
1335
1311
1336
describe ( 'Debounce' , ( ) => {
0 commit comments