@@ -2,32 +2,63 @@ import '@testing-library/jest-dom/extend-expect';
22import React from 'react' ;
33import { render , screen } from '@testing-library/react' ;
44import { ExperimentRunStatus } from '@api/entities' ;
5+ import { ChaosInfrastructureStatus } from '@models' ;
56import StatusBadgeV2 , { StatusBadgeEntity } from '../StatusBadgeV2' ;
67
78describe ( 'StatusBadgeV2' , ( ) => {
8- test ( 'renders with ExperimentRun entity' , ( ) => {
9- render ( < StatusBadgeV2 status = { ExperimentRunStatus . COMPLETED } entity = { StatusBadgeEntity . ExperimentRun } /> ) ;
10- expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
11- } ) ;
9+ describe ( 'ExperimentRun entity' , ( ) => {
10+ test ( 'renders COMPLETED status with correct text' , ( ) => {
11+ render ( < StatusBadgeV2 status = { ExperimentRunStatus . COMPLETED } entity = { StatusBadgeEntity . ExperimentRun } /> ) ;
12+ expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
13+ expect ( screen . getByText ( 'COMPLETED' ) ) . toBeInTheDocument ( ) ;
14+ } ) ;
1215
13- test ( 'renders correct status text' , ( ) => {
14- render ( < StatusBadgeV2 status = { ExperimentRunStatus . RUNNING } entity = { StatusBadgeEntity . ExperimentRun } /> ) ;
15- expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
16- } ) ;
16+ test ( 'renders RUNNING status with correct text' , ( ) => {
17+ render ( < StatusBadgeV2 status = { ExperimentRunStatus . RUNNING } entity = { StatusBadgeEntity . ExperimentRun } /> ) ;
18+ expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
19+ expect ( screen . getByText ( 'RUNNING' ) ) . toBeInTheDocument ( ) ;
20+ } ) ;
21+
22+ test ( 'renders ERROR status with correct text' , ( ) => {
23+ render ( < StatusBadgeV2 status = { ExperimentRunStatus . ERROR } entity = { StatusBadgeEntity . ExperimentRun } /> ) ;
24+ expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
25+ expect ( screen . getByText ( 'ERROR' ) ) . toBeInTheDocument ( ) ;
26+ } ) ;
1727
18- test ( 'renders with tooltip' , ( ) => {
19- render (
20- < StatusBadgeV2
21- status = { ExperimentRunStatus . COMPLETED }
22- entity = { StatusBadgeEntity . ExperimentRun }
23- tooltip = "Test tooltip"
24- />
25- ) ;
26- expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
28+ test ( 'renders STOPPED status with correct text' , ( ) => {
29+ render ( < StatusBadgeV2 status = { ExperimentRunStatus . STOPPED } entity = { StatusBadgeEntity . ExperimentRun } /> ) ;
30+ expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
31+ expect ( screen . getByText ( 'STOPPED' ) ) . toBeInTheDocument ( ) ;
32+ } ) ;
33+
34+ test ( 'renders QUEUED status with correct text' , ( ) => {
35+ render ( < StatusBadgeV2 status = { ExperimentRunStatus . QUEUED } entity = { StatusBadgeEntity . ExperimentRun } /> ) ;
36+ expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
37+ expect ( screen . getByText ( 'QUEUED' ) ) . toBeInTheDocument ( ) ;
38+ } ) ;
39+
40+ test ( 'renders with tooltip prop' , ( ) => {
41+ render (
42+ < StatusBadgeV2
43+ status = { ExperimentRunStatus . COMPLETED }
44+ entity = { StatusBadgeEntity . ExperimentRun }
45+ tooltip = "Test tooltip"
46+ />
47+ ) ;
48+ expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
49+ expect ( screen . getByText ( 'COMPLETED' ) ) . toBeInTheDocument ( ) ;
50+ } ) ;
2751 } ) ;
2852
29- test ( 'renders error status' , ( ) => {
30- render ( < StatusBadgeV2 status = { ExperimentRunStatus . ERROR } entity = { StatusBadgeEntity . ExperimentRun } /> ) ;
31- expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
53+ describe ( 'Infrastructure entity' , ( ) => {
54+ test ( 'renders ACTIVE status with correct text' , ( ) => {
55+ render ( < StatusBadgeV2 status = { ChaosInfrastructureStatus . ACTIVE } entity = { StatusBadgeEntity . Infrastructure } /> ) ;
56+ expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
57+ } ) ;
58+
59+ test ( 'renders INACTIVE status with correct text' , ( ) => {
60+ render ( < StatusBadgeV2 status = { ChaosInfrastructureStatus . INACTIVE } entity = { StatusBadgeEntity . Infrastructure } /> ) ;
61+ expect ( screen . getByTestId ( 'status-badge-v2' ) ) . toBeInTheDocument ( ) ;
62+ } ) ;
3263 } ) ;
3364} ) ;
0 commit comments