您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

response-body.jsx 1.3 KiB

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