Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

53 rader
1.6 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. getConfigs: () => ({
  17. showExtensions: false
  18. }),
  19. name: "Name from props",
  20. depth: 1,
  21. schema: fromJS({
  22. type: "string",
  23. title: "Custom model title"
  24. })
  25. }
  26. it("renders the schema's title", function() {
  27. // When
  28. const wrapper = shallow(<PrimitiveModel {...props}/>)
  29. const modelTitleEl = wrapper.find("span.model-title")
  30. expect(modelTitleEl.length).toEqual(1)
  31. // Then
  32. expect( modelTitleEl.text() ).toEqual( "Custom model title" )
  33. })
  34. it("falls back to the passed-in `name` prop for the title", function() {
  35. // When
  36. props.schema = fromJS({
  37. type: "string"
  38. })
  39. const wrapper = shallow(<PrimitiveModel {...props}/>)
  40. const modelTitleEl = wrapper.find("span.model-title")
  41. expect(modelTitleEl.length).toEqual(1)
  42. // Then
  43. expect( modelTitleEl.text() ).toEqual( "Name from props" )
  44. })
  45. })
  46. } )