From e258909a3f58bfeade7a2f897afa7f150bad2f25 Mon Sep 17 00:00:00 2001 From: Wilson Zeng Date: Tue, 22 May 2018 17:24:13 +0800 Subject: [PATCH] fix(module:popconfirm): add nzOkType support 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 91da55e2f39..3157d1ab905 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 17a992b40ae..9b737ad4504 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 4d4e4624a3b..aeddbabdf79 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;