Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

91 řádky
4.1 KiB

  1. /* eslint-env mocha */
  2. import React from "react"
  3. import expect from "expect"
  4. import { render } from "enzyme"
  5. import Markdown from "components/providers/markdown"
  6. import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.js"
  7. describe("Markdown component", function() {
  8. describe("Swagger 2.0", function() {
  9. it("allows span elements with class attrib", function() {
  10. const str = `<span class="method">ONE</span>`
  11. const el = render(<Markdown source={str} />)
  12. expect(el.html()).toEqual(`<div class="markdown"><p><span class="method">ONE</span></p>\n</div>`)
  13. })
  14. it("allows td elements with colspan attrib", function() {
  15. const str = `<table><tr><td>ABC</td></tr></table>`
  16. const el = render(<Markdown source={str} />)
  17. expect(el.html()).toEqual(`<div class="markdown"><table><tr><td>ABC</td></tr></table></div>`)
  18. })
  19. it("allows image elements", function() {
  20. const str = `![Image alt text](http://image.source "Image title")`
  21. const el = render(<Markdown source={str} />)
  22. expect(el.html()).toEqual(`<div class="markdown"><p><img src="http://image.source" title="Image title"></p>\n</div>`)
  23. })
  24. it("allows image elements with https scheme", function() {
  25. const str = `![Image alt text](https://image.source "Image title")`
  26. const el = render(<Markdown source={str} />)
  27. expect(el.html()).toEqual(`<div class="markdown"><p><img src="https://image.source" title="Image title"></p>\n</div>`)
  28. })
  29. it("allows image elements with data scheme", function() {
  30. const str = `<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==">`
  31. const el = render(<Markdown source={str} />)
  32. expect(el.html()).toEqual(`<div class="markdown"><p>` + str + `</p>\n</div>`)
  33. })
  34. it("allows heading elements", function() {
  35. const str = `
  36. # h1
  37. ## h2
  38. ### h3
  39. #### h4
  40. ##### h5
  41. ###### h6`
  42. const el = render(<Markdown source={str} />)
  43. expect(el.html()).toEqual(`<div class="markdown"><h1>h1</h1>\n<h2>h2</h2>\n<h3>h3</h3>\n<h4>h4</h4>\n<h5>h5</h5>\n<h6>h6</h6>\n</div>`)
  44. })
  45. it("allows links", function() {
  46. const str = `[Link](https://example.com/)`
  47. const el = render(<Markdown source={str} />)
  48. expect(el.html()).toEqual(`<div class="markdown"><p><a href="https://example.com/" target="_blank">Link</a></p>\n</div>`)
  49. })
  50. })
  51. describe("OAS 3", function() {
  52. it("allows image elements", function() {
  53. const str = `![Image alt text](http://image.source "Image title")`
  54. const el = render(<OAS3Markdown source={str} />)
  55. expect(el.html()).toEqual(`<div class="renderedMarkdown"><div><p><img src="http://image.source" title="Image title"></p></div></div>`)
  56. })
  57. it("allows image elements with https scheme", function() {
  58. const str = `![Image alt text](https://image.source "Image title")`
  59. const el = render(<OAS3Markdown source={str} />)
  60. expect(el.html()).toEqual(`<div class="renderedMarkdown"><div><p><img src="https://image.source" title="Image title"></p></div></div>`)
  61. })
  62. it("allows image elements with data scheme", function() {
  63. const str = `<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==">`
  64. const el = render(<OAS3Markdown source={str} />)
  65. expect(el.html()).toEqual(`<div class="renderedMarkdown"><div>` + str + `</div></div>`)
  66. })
  67. it("allows heading elements", function() {
  68. const str = `
  69. # h1
  70. ## h2
  71. ### h3
  72. #### h4
  73. ##### h5
  74. ###### h6`
  75. const el = render(<OAS3Markdown source={str} />)
  76. expect(el.html()).toEqual(`<div class="renderedMarkdown"><div><h1>h1</h1>\n<h2>h2</h2>\n<h3>h3</h3>\n<h4>h4</h4>\n<h5>h5</h5>\n<h6>h6</h6></div></div>`)
  77. })
  78. })
  79. })