@@ -6,6 +6,7 @@ import { By } from '@angular/platform-browser';
66import { NzScrollService } from 'ng-zorro-antd/core/services' ;
77import { NzAnchorModule } from './anchor.module' ;
88import { NzAnchorComponent } from './anchor.component' ;
9+ import { NzDirectionVHType } from 'ng-zorro-antd/core/types' ;
910
1011const throttleTime = 51 ;
1112
@@ -61,6 +62,19 @@ describe('anchor', () => {
6162 } , throttleTime ) ;
6263 } ) ;
6364
65+ it ( 'should actived when scrolling to the anchor - horizontal' , ( done : ( ) => void ) => {
66+ context . nzDirection = 'horizontal' ;
67+ fixture . detectChanges ( ) ;
68+ expect ( context . _scroll ) . not . toHaveBeenCalled ( ) ;
69+ page . scrollTo ( ) ;
70+ setTimeout ( ( ) => {
71+ const inkNode = page . getEl ( '.ant-anchor-ink-ball' ) ;
72+ expect ( + inkNode . style . left ! . replace ( 'px' , '' ) ) . not . toBeNull ( ) ;
73+ expect ( context . _scroll ) . toHaveBeenCalled ( ) ;
74+ done ( ) ;
75+ } , throttleTime ) ;
76+ } ) ;
77+
6478 it ( 'should clean actived when leave all anchor' , fakeAsync ( ( ) => {
6579 spyOn ( context . comp , 'clearActive' as any ) ;
6680 page . scrollTo ( ) ;
@@ -226,6 +240,20 @@ describe('anchor', () => {
226240 } ) ;
227241 } ) ;
228242
243+ describe ( 'direction' , ( ) => {
244+ it ( `should have vertical direction by default` , ( ) => {
245+ const wrapperEl = dl . query ( By . css ( '.ant-anchor-wrapper' ) ) ;
246+ expect ( wrapperEl . nativeElement . classList ) . not . toContain ( 'ant-anchor-wrapper-horizontal' ) ;
247+ } ) ;
248+
249+ it ( `should have correct class name in horizontal mode` , ( ) => {
250+ context . nzDirection = 'horizontal' ;
251+ fixture . detectChanges ( ) ;
252+ const wrapperEl = dl . query ( By . css ( '.ant-anchor-wrapper' ) ) ;
253+ expect ( wrapperEl . nativeElement . classList ) . toContain ( 'ant-anchor-wrapper-horizontal' ) ;
254+ } ) ;
255+ } ) ;
256+
229257 describe ( '**boundary**' , ( ) => {
230258 it ( '#getOffsetTop' , ( done : ( ) => void ) => {
231259 const el1 = document . getElementById ( '何时使用' ) ! ;
@@ -273,6 +301,7 @@ describe('anchor', () => {
273301 [nzTargetOffset]="nzTargetOffset"
274302 [nzContainer]="nzContainer"
275303 [nzCurrentAnchor]="nzCurrentAnchor"
304+ [nzDirection]="nzDirection"
276305 (nzClick)="_click($event)"
277306 (nzScroll)="_scroll($event)"
278307 (nzChange)="_change($event)"
@@ -332,6 +361,7 @@ export class TestComponent {
332361 nzShowInkInFixed = false ;
333362 nzContainer : any = null ;
334363 nzCurrentAnchor ?: string ;
364+ nzDirection : NzDirectionVHType = 'vertical' ;
335365 _click ( ) { }
336366 _change ( ) { }
337367 _scroll ( ) { }
0 commit comments