Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

49 rindas
1.5 KiB

  1. /* eslint-env mocha */
  2. import React from "react"
  3. import expect from "expect"
  4. import { shallow } from "enzyme"
  5. import { fromJS } from "immutable"
  6. import PrimitiveModel from "components/primitive-model"
  7. describe("<PrimitiveModel/>", function() {
  8. describe("Model name", function() {
  9. const dummyComponent = () => null
  10. const components = {
  11. Markdown: dummyComponent,
  12. EnumModel: dummyComponent
  13. }
  14. const props = {
  15. getComponent: c => components[c],
  16. name: "Name from props",
  17. depth: 1,
  18. schema: fromJS({
  19. type: "string",
  20. title: "Custom model title"
  21. })
  22. }
  23. it("renders the schema's title", function() {
  24. // When
  25. const wrapper = shallow(<PrimitiveModel {...props}/>)
  26. const modelTitleEl = wrapper.find("span.model-title")
  27. expect(modelTitleEl.length).toEqual(1)
  28. // Then
  29. expect( modelTitleEl.text() ).toEqual( "Custom model title" )
  30. })
  31. it("falls back to the passed-in `name` prop for the title", function() {
  32. // When
  33. props.schema = fromJS({
  34. type: "string"
  35. })
  36. const wrapper = shallow(<PrimitiveModel {...props}/>)
  37. const modelTitleEl = wrapper.find("span.model-title")
  38. expect(modelTitleEl.length).toEqual(1)
  39. // Then
  40. expect( modelTitleEl.text() ).toEqual( "Name from props" )
  41. })
  42. })
  43. } )