11import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed' ;
22import { Component } from '@angular/core' ;
33import { ComponentFixture , TestBed } from '@angular/core/testing' ;
4- import { SkyAlertModule , SkyIndicatorIconType } from '@skyux/indicators' ;
4+ import {
5+ SkyAlertModule ,
6+ SkyIndicatorDescriptionType ,
7+ SkyIndicatorIconType ,
8+ } from '@skyux/indicators' ;
59
610import { SkyAlertHarness } from './alert-harness' ;
711
@@ -13,6 +17,8 @@ import { SkyAlertHarness } from './alert-harness';
1317 [alertType]="alertType"
1418 [closeable]="closeable"
1519 [closed]="closed"
20+ [customDescription]="customDescription"
21+ [descriptionType]="descriptionType"
1622 (closedChange)="closedChange()"
1723 data-sky-id="test-alert"
1824 >
@@ -28,6 +34,10 @@ class TestComponent {
2834
2935 public closed = false ;
3036
37+ public customDescription : string ;
38+
39+ public descriptionType : SkyIndicatorDescriptionType ;
40+
3141 public closedChange ( ) {
3242 // Only exists for the spy.
3343 }
@@ -44,6 +54,21 @@ async function validateAlertType(
4454 await expectAsync ( alertHarness . getAlertType ( ) ) . toBeResolvedTo ( alertType ) ;
4555}
4656
57+ async function validateDescriptionType (
58+ alertHarness : SkyAlertHarness ,
59+ fixture : ComponentFixture < TestComponent > ,
60+ descriptionType : SkyIndicatorDescriptionType ,
61+ customDescription ?: string
62+ ) {
63+ fixture . componentInstance . descriptionType = descriptionType ;
64+ fixture . componentInstance . customDescription = customDescription ;
65+ fixture . detectChanges ( ) ;
66+
67+ const componentDesciptionType = await alertHarness . getDescriptionType ( ) ;
68+
69+ expect ( componentDesciptionType ) . toEqual ( descriptionType ) ;
70+ }
71+
4772describe ( 'Alert harness' , ( ) => {
4873 async function setupTest ( options : { dataSkyId ?: string } = { } ) {
4974 await TestBed . configureTestingModule ( {
@@ -116,6 +141,52 @@ describe('Alert harness', () => {
116141 await validateAlertType ( alertHarness , fixture , 'warning' ) ;
117142 } ) ;
118143
144+ it ( 'should return the expected description type' , async ( ) => {
145+ const { alertHarness, fixture } = await setupTest ( ) ;
146+ await validateDescriptionType ( alertHarness , fixture , 'attention' ) ;
147+ await validateDescriptionType ( alertHarness , fixture , 'caution' ) ;
148+ await validateDescriptionType ( alertHarness , fixture , 'completed' ) ;
149+ await validateDescriptionType ( alertHarness , fixture , 'danger' ) ;
150+ await validateDescriptionType ( alertHarness , fixture , 'error' ) ;
151+ await validateDescriptionType ( alertHarness , fixture , 'important-info' ) ;
152+ await validateDescriptionType ( alertHarness , fixture , 'important-warning' ) ;
153+ await validateDescriptionType ( alertHarness , fixture , 'success' ) ;
154+ await validateDescriptionType ( alertHarness , fixture , 'warning' ) ;
155+ await validateDescriptionType ( alertHarness , fixture , 'none' ) ;
156+ await validateDescriptionType (
157+ alertHarness ,
158+ fixture ,
159+ 'custom' ,
160+ 'custom text'
161+ ) ;
162+ } ) ;
163+
164+ it ( 'should return the custom description when `descriptionType` is custom' , async ( ) => {
165+ const { fixture, alertHarness } = await setupTest ( ) ;
166+ const description = 'Custom description:' ;
167+
168+ fixture . componentInstance . descriptionType = 'custom' ;
169+ fixture . componentInstance . customDescription = description ;
170+
171+ fixture . detectChanges ( ) ;
172+
173+ const componentDesciption = await alertHarness . getCustomDescription ( ) ;
174+
175+ expect ( componentDesciption ) . toEqual ( description ) ;
176+ } ) ;
177+
178+ it ( 'should return an empty string when `descriptionType` is not custom' , async ( ) => {
179+ const { fixture, alertHarness } = await setupTest ( ) ;
180+
181+ fixture . componentInstance . descriptionType = 'attention' ;
182+
183+ fixture . detectChanges ( ) ;
184+
185+ const componentDesciption = await alertHarness . getCustomDescription ( ) ;
186+
187+ expect ( componentDesciption ) . toEqual ( '' ) ;
188+ } ) ;
189+
119190 it ( 'should return the expected text' , async ( ) => {
120191 const { alertHarness } = await setupTest ( ) ;
121192 await expectAsync ( alertHarness . getText ( ) ) . toBeResolvedTo (
0 commit comments