Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

49 lignes
1.7 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 image elements", function() {
  10. const str = `![Image alt text](http://image.source "Image title")`
  11. const el = render(<Markdown source={str} />)
  12. expect(el.html()).toEqual(`<div class="markdown"><p><img src="http://image.source" title="Image title"></p>\n</div>`)
  13. })
  14. it("allows heading elements", function() {
  15. const str = `
  16. # h1
  17. ## h2
  18. ### h3
  19. #### h4
  20. ##### h5
  21. ###### h6`
  22. const el = render(<Markdown source={str} />)
  23. 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>`)
  24. })
  25. })
  26. describe("OAS 3", function() {
  27. it("allows image elements", function() {
  28. const str = `![Image alt text](http://image.source "Image title")`
  29. const el = render(<OAS3Markdown source={str} />)
  30. expect(el.html()).toEqual(`<div class="renderedMarkdown"><div><p><img src="http://image.source" title="Image title"></p></div></div>`)
  31. })
  32. it("allows heading elements", function() {
  33. const str = `
  34. # h1
  35. ## h2
  36. ### h3
  37. #### h4
  38. ##### h5
  39. ###### h6`
  40. const el = render(<OAS3Markdown source={str} />)
  41. 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>`)
  42. })
  43. })
  44. })