@@ -1689,6 +1689,18 @@ describe('cascader', () => {
16891689 expect ( element . classList . contains ( 'ant-select-dropdown-placement-topLeft' ) ) . toBe ( false ) ;
16901690 expect ( element . classList . contains ( 'ant-select-dropdown-placement-topRight' ) ) . toBe ( true ) ;
16911691 } ) ) ;
1692+
1693+ it ( 'should cascade work when the value of ngModel that is not existed in options' , fakeAsync ( ( ) => {
1694+ fixture . detectChanges ( ) ;
1695+ testComponent . values = [ 'zhejiang' , 'a' ] ;
1696+ testComponent . cascader . setMenuVisible ( true ) ;
1697+ fixture . detectChanges ( ) ;
1698+ getItemAtColumnAndRow ( 1 , 1 ) ! . click ( ) ;
1699+ getItemAtColumnAndRow ( 2 , 1 ) ! . click ( ) ;
1700+ getItemAtColumnAndRow ( 3 , 1 ) ! . click ( ) ;
1701+ fixture . detectChanges ( ) ;
1702+ expect ( testComponent . values ) . toEqual ( [ 'zhejiang' , 'hangzhou' , 'xihu' ] ) ;
1703+ } ) ) ;
16921704 } ) ;
16931705
16941706 describe ( 'multiple' , ( ) => {
@@ -1866,6 +1878,42 @@ describe('cascader', () => {
18661878 fixture . detectChanges ( ) ;
18671879 expect ( testComponent . onChanges ) . toHaveBeenCalledWith ( [ [ 'light' ] ] ) ;
18681880 } ) ) ;
1881+
1882+ describe ( 'should cascade work when the value of ngModel includes nodes that are not existed in options' , ( ) => {
1883+ it ( 'should remove item work' , fakeAsync ( ( ) => {
1884+ setValues ( 2 ) ;
1885+ testComponent . values ! [ 0 ] = [ 'light' , 'a' ] ;
1886+ tick ( ) ;
1887+ fixture . detectChanges ( ) ;
1888+ const removeBtn = cascader . queryAll ( By . css ( '.ant-select-selection-item-remove' ) ) [ 0 ] ;
1889+ removeBtn . nativeElement . click ( ) ;
1890+ fixture . detectChanges ( ) ;
1891+ const tags = cascader . queryAll ( By . directive ( NzSelectItemComponent ) ) ;
1892+ expect ( tags . length ) . toBe ( 1 ) ;
1893+ } ) ) ;
1894+
1895+ it ( 'should add item work' , fakeAsync ( ( ) => {
1896+ spyOn ( testComponent , 'onChanges' ) ;
1897+ setValues ( 2 ) ;
1898+ testComponent . values ! [ 0 ] = [ 'light' , 'a' ] ;
1899+ console . log ( testComponent . values ) ;
1900+ tick ( ) ;
1901+ fixture . detectChanges ( ) ;
1902+ cascader . componentInstance . setMenuVisible ( true ) ;
1903+ fixture . detectChanges ( ) ;
1904+ const checkbox = getCheckboxAtColumnAndRow ( 2 , 3 ) ! ;
1905+ checkbox . click ( ) ;
1906+ fixture . detectChanges ( ) ;
1907+ expect ( testComponent . values ! . length ) . toBe ( 3 ) ;
1908+ const selectedNodes = [
1909+ [ 'light' , 1 ] ,
1910+ [ 'light' , 'a' ] ,
1911+ [ 'light' , 2 ]
1912+ ] ;
1913+ expect ( testComponent . values ) . toEqual ( selectedNodes ) ;
1914+ expect ( testComponent . onChanges ) . toHaveBeenCalledWith ( selectedNodes ) ;
1915+ } ) ) ;
1916+ } ) ;
18691917 } ) ;
18701918
18711919 describe ( 'load data lazily' , ( ) => {
0 commit comments