Skip to content

Commit

Permalink
feat(module:steps): supports enable and disable (#6101)
Browse files Browse the repository at this point in the history
close #5579
  • Loading branch information
stygian-desolator authored Nov 30, 2020
1 parent edffdee commit b87e72d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
13 changes: 11 additions & 2 deletions components/steps/step.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ import { Subject } from 'rxjs';
status: nzStatus,
index: index
}"
>
</ng-template>
></ng-template>
</span>
</ng-template>
</div>
Expand Down Expand Up @@ -154,6 +153,16 @@ export class NzStepComponent implements OnDestroy {
}
}

enable(): void {
this.nzDisabled = false;
this.cdr.markForCheck();
}

disable(): void {
this.nzDisabled = true;
this.cdr.markForCheck();
}

markForCheck(): void {
this.cdr.markForCheck();
}
Expand Down
18 changes: 18 additions & 0 deletions components/steps/steps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,24 @@ describe('steps', () => {
fixture.detectChanges();
expect(testComponent.onIndexChange).not.toHaveBeenCalled();
}));

it('should enable and disable work', fakeAsync(() => {
fixture.detectChanges();
tick();
fixture.detectChanges();
innerSteps[1].componentInstance.disable();
fixture.detectChanges();
spyOn(testComponent, 'onIndexChange');
innerSteps[1].nativeElement.querySelector('.ant-steps-item-container').click();
fixture.detectChanges();
expect(testComponent.onIndexChange).not.toHaveBeenCalled();
innerSteps[1].componentInstance.enable();
fixture.detectChanges();
innerSteps[1].nativeElement.querySelector('.ant-steps-item-container').click();
fixture.detectChanges();
expect(testComponent.onIndexChange).toHaveBeenCalledTimes(1);
expect(testComponent.onIndexChange).toHaveBeenCalledWith(1);
}));
});

describe('navigation', () => {
Expand Down

0 comments on commit b87e72d

Please sign in to comment.