-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add tests for alert component
Co-authored-by: smeligrana <[email protected]>
- Loading branch information
1 parent
b4cb467
commit d27a725
Showing
1 changed file
with
47 additions
and
6 deletions.
There are no files selected for viewing
53 changes: 47 additions & 6 deletions
53
projects/design-angular-kit/src/lib/components/core/alert/alert.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,63 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ItAlertComponent } from './alert.component'; | ||
import { tb_base } from '../../../../test'; | ||
import { By } from '@angular/platform-browser'; | ||
import { Component, Input } from '@angular/core'; | ||
import { AlertColor } from '../../../interfaces/core'; | ||
|
||
@Component( | ||
{ | ||
selector: 'it-unit-test', | ||
template: ` | ||
<it-alert [color]="selectedColor" [dismissible]="isDismissible"> | ||
Questo è un alert di tipo "<b>primary</b>". | ||
</it-alert> | ||
` | ||
} | ||
) | ||
class UnitTestComponent { | ||
|
||
@Input() set selectedColor(value: AlertColor | undefined) { this._selectedColor = value; } | ||
get selectedColor(): AlertColor | undefined { return this._selectedColor; } | ||
private _selectedColor: AlertColor | undefined = undefined; | ||
|
||
@Input() set isDismissible(value: boolean) { this._dismissible = value; } | ||
get isDismissible(): boolean { return this._dismissible; } | ||
|
||
private _dismissible: boolean = false; | ||
} | ||
|
||
let component: UnitTestComponent; | ||
let fixture: ComponentFixture<UnitTestComponent>; | ||
describe('ItAlertComponent', () => { | ||
let component: ItAlertComponent; | ||
let fixture: ComponentFixture<ItAlertComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule(tb_base) | ||
.compileComponents(); | ||
TestBed.configureTestingModule({ | ||
declarations: [UnitTestComponent], | ||
imports: [ItAlertComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ItAlertComponent); | ||
fixture = TestBed.createComponent(UnitTestComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('Dovrebbe avere colore primary', () => { | ||
component.selectedColor = 'primary'; | ||
fixture.detectChanges(); | ||
const spanElement = fixture.debugElement.query(By.css('div.alert.alert-primary')); | ||
expect(spanElement).toBeTruthy(); | ||
}); | ||
|
||
it('Dovrebbe avere colore success', () => { | ||
component.selectedColor = 'success'; | ||
fixture.detectChanges(); | ||
const spanElement = fixture.debugElement.query(By.css('div.alert.alert-success')); | ||
expect(spanElement).toBeTruthy(); | ||
}); | ||
|
||
}); |
d27a725
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
design-angular-kit – ./
design-angular-kit-dip-trasformazione-digitale.vercel.app
design-angular-kit.vercel.app
design-angular-kit-git-main-dip-trasformazione-digitale.vercel.app