eventOrGroupHeader.spec.jsx 3.2 KB

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