Skip to content

Commit

Permalink
fix(module: badge): fixed badge test case error (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
sWhite01111 authored and 3fuyu committed Oct 31, 2018
1 parent ec5fd1f commit 6089651
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions components/badge/badge.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ng-content></ng-content>
<sup *ngIf="dot || text"
[ngClass]="scrollNumberCls"
[ngStyle]="style">{{text}}
</sup>
[ngClass]="scrollNumberCls"
[ngStyle]="style">{{text}}
</sup>
12 changes: 6 additions & 6 deletions components/badge/badge.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ describe('BadgeComponent', () => {
it('should corner work ', () => {
component.text = 'corner is false';
fixture.detectChanges();
expect(badgeEle.nativeElement.querySelector('.am-badge-text').innerText).toBe(
expect(badgeEle.nativeElement.querySelector('.am-badge-text').innerText.trim()).toBe(
'corner is false',
'dot is false,corner is false'
);

component.corner = true;
fixture.detectChanges();
expect(badgeEle.nativeElement.querySelector('.am-badge-text')).toBeNull('dot=false,corner is true');
expect(badgeEle.nativeElement.querySelector('.am-badge-corner').innerText).toBe(
expect(badgeEle.nativeElement.querySelector('.am-badge-corner').innerText.trim()).toBe(
'corner is false',
'dot is false,corner is true'
);
expect(badgeEle.nativeElement.classList).toContain('am-badge-corner-wrapper', 'am-badge-corner-wrapper');

component.size = 'large';
fixture.detectChanges();
expect(badgeEle.nativeElement.querySelector('.am-badge-corner-large').innerText).toBe(
expect(badgeEle.nativeElement.querySelector('.am-badge-corner-large').innerText.trim()).toBe(
'corner is false',
'dot is false,corner is true'
);
Expand All @@ -69,16 +69,16 @@ describe('BadgeComponent', () => {
component.dot = false;
component.text = 'test';
fixture.detectChanges();
expect(badgeEle.nativeElement.querySelector('.am-badge-text').innerText).toBe('test', 'dot=false,text is show');
expect(badgeEle.nativeElement.querySelector('.am-badge-text').innerText.trim()).toBe('test', 'dot=false,text is show');
});
it('when text is number,should overflowCount work', () => {
component.text = 11;
fixture.detectChanges();
expect(badgeEle.nativeElement.querySelector('.am-badge-text').innerText).toBe('11', 'test is 11');
expect(badgeEle.nativeElement.querySelector('.am-badge-text').innerText.trim()).toBe('11', 'test is 11');

component.text = 35;
fixture.detectChanges();
expect(badgeEle.nativeElement.querySelector('.am-badge-text').innerText).toBe('33+', 'test is 33+');
expect(badgeEle.nativeElement.querySelector('.am-badge-text').innerText.trim()).toBe('33+', 'test is 33+');
});
it('should hot work', () => {
expect(badgeEle.nativeElement.querySelector('.am-badge-hot')).toBeNull('hot is false');
Expand Down

0 comments on commit 6089651

Please sign in to comment.