Skip to content

Commit add0627

Browse files
fix: add tests
1 parent 2dfa5aa commit add0627

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
});

0 commit comments

Comments
 (0)