toggleRawEventData.spec.jsx 1.9 KB

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