eventOrGroupHeader.spec.jsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import React from 'react';
  2. import {shallow} from 'sentry-test/enzyme';
  3. import toJson from 'enzyme-to-json';
  4. import EventOrGroupHeader from 'app/components/eventOrGroupHeader';
  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('EventOrGroupHeader', function() {
  17. describe('Group', function() {
  18. const groupData = {
  19. ...data,
  20. level: 'error',
  21. id: 'id',
  22. };
  23. it('renders with `type = error`', function() {
  24. const component = shallow(
  25. <EventOrGroupHeader
  26. orgId="orgId"
  27. data={{
  28. ...groupData,
  29. ...{
  30. type: 'error',
  31. },
  32. }}
  33. />
  34. );
  35. expect(toJson(component)).toMatchSnapshot();
  36. });
  37. it('renders with `type = csp`', function() {
  38. const component = shallow(
  39. <EventOrGroupHeader
  40. params={{orgId: 'orgId'}}
  41. data={{
  42. ...groupData,
  43. ...{
  44. type: 'csp',
  45. },
  46. }}
  47. />
  48. );
  49. expect(toJson(component)).toMatchSnapshot();
  50. });
  51. it('renders with `type = default`', function() {
  52. const component = shallow(
  53. <EventOrGroupHeader
  54. params={{orgId: 'orgId'}}
  55. data={{
  56. ...groupData,
  57. ...{
  58. type: 'default',
  59. },
  60. }}
  61. />
  62. );
  63. expect(toJson(component)).toMatchSnapshot();
  64. });
  65. });
  66. describe('Event', function() {
  67. const eventData = {
  68. ...data,
  69. id: 'id',
  70. eventID: 'eventID',
  71. groupID: 'groupID',
  72. culprit: undefined,
  73. };
  74. it('renders with `type = error`', function() {
  75. const component = shallow(
  76. <EventOrGroupHeader
  77. params={{orgId: 'orgId'}}
  78. data={{
  79. ...eventData,
  80. ...{
  81. type: 'error',
  82. },
  83. }}
  84. />
  85. );
  86. expect(toJson(component)).toMatchSnapshot();
  87. });
  88. it('renders with `type = csp`', function() {
  89. const component = shallow(
  90. <EventOrGroupHeader
  91. params={{orgId: 'orgId'}}
  92. data={{
  93. ...eventData,
  94. ...{
  95. type: 'csp',
  96. },
  97. }}
  98. />
  99. );
  100. expect(toJson(component)).toMatchSnapshot();
  101. });
  102. it('renders with `type = default`', function() {
  103. const component = shallow(
  104. <EventOrGroupHeader
  105. params={{orgId: 'orgId'}}
  106. data={{
  107. ...eventData,
  108. ...{
  109. type: 'default',
  110. },
  111. }}
  112. />
  113. );
  114. expect(toJson(component)).toMatchSnapshot();
  115. });
  116. it('hides level tag', function() {
  117. const component = shallow(
  118. <EventOrGroupHeader
  119. projectId="projectId"
  120. hideLevel
  121. data={{
  122. ...eventData,
  123. ...{
  124. type: 'default',
  125. },
  126. }}
  127. />
  128. );
  129. expect(toJson(component)).toMatchSnapshot();
  130. });
  131. });
  132. });