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ů.
 
 
 
 

34 řádky
1.0 KiB

  1. /* eslint-env mocha */
  2. import React from "react"
  3. import expect from "expect"
  4. import { render } from "enzyme"
  5. import { fromJS } from "immutable"
  6. import Info from "components/info"
  7. import Markdown from "components/providers/markdown"
  8. describe("<Info/> Sanitization", function(){
  9. const dummyComponent = () => null
  10. const components = {
  11. Markdown
  12. }
  13. const props = {
  14. getComponent: c => components[c] || dummyComponent,
  15. info: fromJS({
  16. title: "Test Title **strong** <script>alert(1)</script>",
  17. description: "Description *with* <script>Markdown</script>"
  18. }),
  19. host: "example.test",
  20. basePath: "/api"
  21. }
  22. it("renders sanitized .title content", function(){
  23. let wrapper = render(<Info {...props}/>)
  24. expect(wrapper.find(".title").html()).toEqual("Test Title **strong** &lt;script&gt;alert(1)&lt;/script&gt;")
  25. })
  26. it("renders sanitized .description content", function() {
  27. let wrapper = render(<Info {...props}/>)
  28. expect(wrapper.find(".description").html()).toEqual("<div class=\"markdown\"><p>Description <em>with</em> </p>\n</div>")
  29. })
  30. })