1- import startCase from 'lodash/startCase' ;
21import { EventFixture } from 'sentry-fixture/event' ;
32import { GroupFixture } from 'sentry-fixture/group' ;
43import { ProjectFixture } from 'sentry-fixture/project' ;
54
65import { render , screen } from 'sentry-test/reactTestingLibrary' ;
76
87import ContextCard from 'sentry/components/events/contexts/contextCard' ;
8+ import * as utils from 'sentry/components/events/contexts/utils' ;
99
1010describe ( 'ContextCard' , function ( ) {
1111 const group = GroupFixture ( ) ;
@@ -42,7 +42,7 @@ describe('ContextCard', function () {
4242 />
4343 ) ;
4444
45- expect ( screen . getByText ( startCase ( alias ) ) ) . toBeInTheDocument ( ) ;
45+ expect ( screen . getByText ( alias ) ) . toBeInTheDocument ( ) ;
4646 Object . entries ( simpleContext ) . forEach ( ( [ key , value ] ) => {
4747 expect ( screen . getByText ( key ) ) . toBeInTheDocument ( ) ;
4848 expect ( screen . getByText ( value ) ) . toBeInTheDocument ( ) ;
@@ -57,10 +57,11 @@ describe('ContextCard', function () {
5757
5858 it ( 'renders with icons if able' , function ( ) {
5959 const event = EventFixture ( ) ;
60+ const iconSpy = jest . spyOn ( utils , 'getContextIcon' ) ;
6061
6162 const browserContext = {
6263 type : 'browser' ,
63- name : 'Firefox ' ,
64+ name : 'firefox ' ,
6465 version : 'Infinity' ,
6566 } ;
6667 const browserCard = render (
@@ -73,7 +74,8 @@ describe('ContextCard', function () {
7374 project = { project }
7475 />
7576 ) ;
76- expect ( screen . getByRole ( 'img' ) ) . toBeInTheDocument ( ) ;
77+ expect ( iconSpy . mock . results [ 0 ] . value . props . name ) . toBe ( 'firefox' ) ;
78+ iconSpy . mockReset ( ) ;
7779 browserCard . unmount ( ) ;
7880
7981 const unknownContext = {
@@ -91,7 +93,7 @@ describe('ContextCard', function () {
9193 project = { project }
9294 />
9395 ) ;
94- expect ( screen . queryByRole ( 'img' ) ) . not . toBeInTheDocument ( ) ;
96+ expect ( iconSpy . mock . results [ 0 ] . value ) . toBeUndefined ( ) ;
9597 } ) ;
9698
9799 it ( 'renders the annotated text and errors' , function ( ) {
0 commit comments