File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
projects/components/src/metric-card Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ import { createComponentFactory } from '@ngneat/spectator/jest' ;
2+ import { MockComponent } from 'ng-mocks' ;
3+ import { IconType } from '@hypertrace/assets-library' ;
4+ import { IconComponent } from '../icon/icon.component' ;
5+ import { MetricCardComponent } from './metric-card.component' ;
6+ import { MetricCardIndicatorType } from './metric-card' ;
7+
8+ describe ( 'Metric Card Component' , ( ) => {
9+ const createComponent = createComponentFactory ( {
10+ component : MetricCardComponent ,
11+ declarations : [ MockComponent ( IconComponent ) ] ,
12+ shallow : true
13+ } ) ;
14+
15+ test ( 'should render everything correctly' , ( ) => {
16+ const spectator = createComponent ( {
17+ props : {
18+ value : 123
19+ }
20+ } ) ;
21+
22+ expect ( spectator . query ( '.metric-card' ) ) . toExist ( ) ;
23+ expect ( spectator . query ( '.dot' ) ) . toExist ( ) ;
24+ expect ( spectator . query ( '.value' ) ) . toHaveText ( '123' ) ;
25+ expect ( spectator . query ( IconComponent ) ) . not . toExist ( ) ;
26+
27+ spectator . setInput ( {
28+ icon : IconType . Add ,
29+ indicator : MetricCardIndicatorType . Icon
30+ } ) ;
31+
32+ expect ( spectator . query ( '.dot' ) ) . not . toExist ( ) ;
33+ expect ( spectator . query ( IconComponent ) ) . toExist ( ) ;
34+ } ) ;
35+ } ) ;
You can’t perform that action at this time.
0 commit comments