Skip to content

Commit

Permalink
fix(module:button): add ant-btn-default class (#8501)
Browse files Browse the repository at this point in the history
  • Loading branch information
HyperLife1119 committed Apr 18, 2024
1 parent 886138d commit 1588199
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion components/button/button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
SimpleChanges,
ViewEncapsulation
} from '@angular/core';
import { fromEvent, Subject } from 'rxjs';
import { Subject, fromEvent } from 'rxjs';
import { filter, startWith, takeUntil } from 'rxjs/operators';

import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
Expand Down Expand Up @@ -50,6 +50,7 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'button';
`,
host: {
class: 'ant-btn',
'[class.ant-btn-default]': `nzType === 'default'`,
'[class.ant-btn-primary]': `nzType === 'primary'`,
'[class.ant-btn-dashed]': `nzType === 'dashed'`,
'[class.ant-btn-link]': `nzType === 'link'`,
Expand Down
5 changes: 4 additions & 1 deletion components/button/button.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BidiModule, Dir } from '@angular/cdk/bidi';
import { ApplicationRef, Component, Input, OnInit, ViewChild } from '@angular/core';
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';

import { ɵComponentBed as ComponentBed, ɵcreateComponentBed as createComponentBed } from 'ng-zorro-antd/core/testing';
Expand Down Expand Up @@ -51,6 +51,9 @@ describe('button', () => {
expect(buttonElement.classList).toContain('ant-btn-block');
});
it('should apply classname based on nzType', () => {
testBed.component.nzType = 'default';
testBed.fixture.detectChanges();
expect(buttonElement.classList).toContain('ant-btn-default');
testBed.component.nzType = 'primary';
testBed.fixture.detectChanges();
expect(buttonElement.classList).toContain('ant-btn-primary');
Expand Down

0 comments on commit 1588199

Please sign in to comment.