1
- import startCase from 'lodash/startCase' ;
2
1
import { EventFixture } from 'sentry-fixture/event' ;
3
2
import { GroupFixture } from 'sentry-fixture/group' ;
4
3
import { ProjectFixture } from 'sentry-fixture/project' ;
5
4
6
5
import { render , screen } from 'sentry-test/reactTestingLibrary' ;
7
6
8
7
import ContextCard from 'sentry/components/events/contexts/contextCard' ;
8
+ import * as utils from 'sentry/components/events/contexts/utils' ;
9
9
10
10
describe ( 'ContextCard' , function ( ) {
11
11
const group = GroupFixture ( ) ;
@@ -42,7 +42,7 @@ describe('ContextCard', function () {
42
42
/>
43
43
) ;
44
44
45
- expect ( screen . getByText ( startCase ( alias ) ) ) . toBeInTheDocument ( ) ;
45
+ expect ( screen . getByText ( alias ) ) . toBeInTheDocument ( ) ;
46
46
Object . entries ( simpleContext ) . forEach ( ( [ key , value ] ) => {
47
47
expect ( screen . getByText ( key ) ) . toBeInTheDocument ( ) ;
48
48
expect ( screen . getByText ( value ) ) . toBeInTheDocument ( ) ;
@@ -57,10 +57,11 @@ describe('ContextCard', function () {
57
57
58
58
it ( 'renders with icons if able' , function ( ) {
59
59
const event = EventFixture ( ) ;
60
+ const iconSpy = jest . spyOn ( utils , 'getContextIcon' ) ;
60
61
61
62
const browserContext = {
62
63
type : 'browser' ,
63
- name : 'Firefox ' ,
64
+ name : 'firefox ' ,
64
65
version : 'Infinity' ,
65
66
} ;
66
67
const browserCard = render (
@@ -73,7 +74,8 @@ describe('ContextCard', function () {
73
74
project = { project }
74
75
/>
75
76
) ;
76
- expect ( screen . getByRole ( 'img' ) ) . toBeInTheDocument ( ) ;
77
+ expect ( iconSpy . mock . results [ 0 ] . value . props . name ) . toBe ( 'firefox' ) ;
78
+ iconSpy . mockReset ( ) ;
77
79
browserCard . unmount ( ) ;
78
80
79
81
const unknownContext = {
@@ -91,7 +93,7 @@ describe('ContextCard', function () {
91
93
project = { project }
92
94
/>
93
95
) ;
94
- expect ( screen . queryByRole ( 'img' ) ) . not . toBeInTheDocument ( ) ;
96
+ expect ( iconSpy . mock . results [ 0 ] . value ) . toBeUndefined ( ) ;
95
97
} ) ;
96
98
97
99
it ( 'renders the annotated text and errors' , function ( ) {
0 commit comments