選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

31 行
1.1 KiB

  1. import React from "react"
  2. import expect from "expect"
  3. import { shallow } from "enzyme"
  4. import HighlightCode from "components/highlight-code"
  5. const fakeGetConfigs = () => ({syntaxHighlight: {activated: true, theme: "agate"}})
  6. describe("<HighlightCode />", () => {
  7. it("should render a Download button if downloadable", () => {
  8. const props = {downloadable: true, getConfigs: fakeGetConfigs }
  9. const wrapper = shallow(<HighlightCode {...props} />)
  10. expect(wrapper.find(".download-contents").length).toEqual(1)
  11. })
  12. it("should render a Copy To Clipboard button if copyable", () => {
  13. const props = {canCopy: true, getConfigs: fakeGetConfigs }
  14. const wrapper = shallow(<HighlightCode {...props} />)
  15. expect(wrapper.find("CopyToClipboard").length).toEqual(1)
  16. })
  17. it("should render values in a preformatted element", () => {
  18. const value = "test text"
  19. const props = {value: value, getConfigs: fakeGetConfigs}
  20. const wrapper = shallow(<HighlightCode {...props} />)
  21. const preTag = wrapper.find("pre")
  22. expect(preTag.length).toEqual(1)
  23. expect(preTag.contains(value)).toEqual(true)
  24. })
  25. })