toggleRawEventData.spec.jsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import {render} from 'sentry-test/reactTestingLibrary';
  2. import EventDataSection from 'sentry/components/events/eventDataSection';
  3. import KeyValueList from 'sentry/components/events/interfaces/keyValueList';
  4. const data = {
  5. metadata: {
  6. title: 'metadata title',
  7. type: 'metadata type',
  8. directive: 'metadata directive',
  9. uri: 'metadata uri',
  10. value: 'metadata value',
  11. message: 'metadata message',
  12. },
  13. culprit: 'culprit',
  14. };
  15. describe('EventDataSection', function () {
  16. const groupData = {
  17. ...data,
  18. level: 'error',
  19. id: 'id',
  20. };
  21. const eventData = {
  22. ...data,
  23. id: 'id',
  24. eventID: 'eventID',
  25. groupID: 'groupID',
  26. culprit: undefined,
  27. };
  28. it('renders formatted', function () {
  29. const wrapper = render(
  30. <EventDataSection
  31. group={groupData}
  32. event={eventData}
  33. type="extra"
  34. title="Additional Data"
  35. raw={false}
  36. />
  37. );
  38. expect(wrapper.container).toSnapshot();
  39. });
  40. it('renders raw', function () {
  41. const wrapper = render(
  42. <EventDataSection
  43. group={groupData}
  44. event={eventData}
  45. type="extra"
  46. title="Additional Data"
  47. raw
  48. />
  49. );
  50. expect(wrapper.container).toSnapshot();
  51. });
  52. });
  53. describe('KeyValueList', function () {
  54. const context = {
  55. somestuff: {andsomeotherstuff: 'here'},
  56. plussomeotherstuff: 'here',
  57. andthis: 0,
  58. };
  59. const extraDataArray = Object.entries(context).map(([key, value]) => ({
  60. key,
  61. value,
  62. subject: key,
  63. }));
  64. it('renders formatted', function () {
  65. const wrapper = render(
  66. <KeyValueList data={extraDataArray} isContextData raw={false} />
  67. );
  68. expect(wrapper.container).toSnapshot();
  69. });
  70. it('renders raw', function () {
  71. const wrapper = render(<KeyValueList data={extraDataArray} isContextData raw />);
  72. expect(wrapper.container).toSnapshot();
  73. });
  74. });