toggleRawEventData.spec.jsx 1.8 KB

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