From 6f394a47a53b905d17f58999912260e2da47e958 Mon Sep 17 00:00:00 2001 From: Wilson Zeng Date: Tue, 22 May 2018 17:43:47 +0800 Subject: [PATCH] fix(module:popconfirm): add nzOkType support (#1492) close #1312 --- .../popconfirm/nz-popconfirm.component.html | 2 +- components/popconfirm/nz-popconfirm.component.ts | 1 + components/popconfirm/nz-popconfirm.spec.ts | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/components/popconfirm/nz-popconfirm.component.html b/components/popconfirm/nz-popconfirm.component.html index 91da55e2f3..3157d1ab90 100644 --- a/components/popconfirm/nz-popconfirm.component.html +++ b/components/popconfirm/nz-popconfirm.component.html @@ -25,7 +25,7 @@ {{ nzCancelText }} {{ 'Modal.cancelText' | nzI18n }} - diff --git a/components/popconfirm/nz-popconfirm.component.ts b/components/popconfirm/nz-popconfirm.component.ts index 17a992b40a..9b737ad450 100644 --- a/components/popconfirm/nz-popconfirm.component.ts +++ b/components/popconfirm/nz-popconfirm.component.ts @@ -29,6 +29,7 @@ export class NzPopconfirmComponent extends NzToolTipComponent { _hasBackdrop = true; @Input() nzContent; @Input() nzOkText: string; + @Input() nzOkType: string = 'primary'; @Input() nzCancelText: string; @Input() diff --git a/components/popconfirm/nz-popconfirm.spec.ts b/components/popconfirm/nz-popconfirm.spec.ts index 4d4e4624a3..aeddbabdf7 100644 --- a/components/popconfirm/nz-popconfirm.spec.ts +++ b/components/popconfirm/nz-popconfirm.spec.ts @@ -58,6 +58,18 @@ describe('NzPopconfirm', () => { expect(overlayContainerElement.textContent).not.toContain(featureKey); })); + it('should support nzOkType', fakeAsync(() => { + demoAppComponent.nzOkType = 'danger'; + const triggerElement = demoAppComponent.normalTrigger.nativeElement; + + dispatchMouseEvent(triggerElement, 'mouseenter'); + demoAppFixture.detectChanges(); + tick(150); // wait for the default 100ms delay + demoAppFixture.detectChanges(); + tick(); + expect(!!overlayContainerElement.querySelector('button.ant-btn-danger')).toBeTruthy(); + })); + it('should show tooltip with custom template', fakeAsync(() => { const triggerElement = demoAppComponent.templateTrigger.nativeElement; @@ -144,7 +156,7 @@ describe('NzPopconfirm', () => { @Component({ selector: 'nz-demo-app', template: ` - Show + Show @@ -163,6 +175,8 @@ describe('NzPopconfirm', () => { ` }) export class DemoAppComponent { + nzOkType = 'primary'; + @ViewChild('normalTrigger') normalTrigger: ElementRef; @ViewChild('templateTrigger') templateTrigger: ElementRef;