You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

44 lines
1.5 KiB

  1. import React from "react"
  2. import expect from "expect"
  3. import { shallow } from "enzyme"
  4. import ResponseBody from "components/response-body"
  5. describe("<ResponseBody />", function() {
  6. const highlightCodeComponent = () => null
  7. const components = {
  8. highlightCode: highlightCodeComponent
  9. }
  10. const props = {
  11. getComponent: c => components[c],
  12. }
  13. it("renders ResponseBody as 'application/json'", function() {
  14. props.contentType = "application/json"
  15. props.content = "{\"key\": \"a test value\"}"
  16. const wrapper = shallow(<ResponseBody {...props}/>)
  17. expect(wrapper.find("highlightCodeComponent").length).toEqual(1)
  18. })
  19. it("renders ResponseBody as 'text/html'", function() {
  20. props.contentType = "application/json"
  21. props.content = "<b>Result</b>"
  22. const wrapper = shallow(<ResponseBody {...props}/>)
  23. expect(wrapper.find("highlightCodeComponent").length).toEqual(1)
  24. })
  25. it("renders ResponseBody as 'image/svg'", function() {
  26. props.contentType = "image/svg"
  27. const wrapper = shallow(<ResponseBody {...props}/>)
  28. console.warn(wrapper.debug())
  29. expect(wrapper.find("highlightCodeComponent").length).toEqual(0)
  30. })
  31. it("should render a copyable highlightCodeComponent for text types", function() {
  32. props.contentType = "text/plain"
  33. props.content = "test text"
  34. const wrapper = shallow(<ResponseBody {...props}/>)
  35. console.warn(wrapper.debug())
  36. expect(wrapper.find("highlightCodeComponent[canCopy]").length).toEqual(1)
  37. })
  38. })