diff options
| author | Zog | 2018-01-25 12:43:56 +0100 | 
|---|---|---|
| committer | Zog | 2018-01-25 12:43:56 +0100 | 
| commit | bee0dd605e416833c680bdc9fafefbb5c1392ff6 (patch) | |
| tree | 66c0b4f0b65fa60b969247c8c9a41f17f60b94d1 /spec/javascript | |
| parent | 050772225bdff8ef165c1e8e841b1eec664d6c99 (diff) | |
| download | chouette-core-bee0dd605e416833c680bdc9fafefbb5c1392ff6.tar.bz2 | |
Refs #5598 @1h; Add specs5598-fix-journey-patterns-collection
Diffstat (limited to 'spec/javascript')
| -rw-r--r-- | spec/javascript/journey_patterns/components/JourneyPattern_spec.js | 63 | ||||
| -rw-r--r-- | spec/javascript/journey_patterns/components/__snapshots__/JourneyPattern_spec.js.snap | 143 | 
2 files changed, 206 insertions, 0 deletions
| diff --git a/spec/javascript/journey_patterns/components/JourneyPattern_spec.js b/spec/javascript/journey_patterns/components/JourneyPattern_spec.js new file mode 100644 index 000000000..0da75ad47 --- /dev/null +++ b/spec/javascript/journey_patterns/components/JourneyPattern_spec.js @@ -0,0 +1,63 @@ +import React, { Component } from 'react' +import JourneyPattern from '../../../../app/javascript/journey_patterns/components/JourneyPattern' +import renderer from 'react-test-renderer' + +describe('the edit button', () => { +  set('policy', () => { +    return {} +  }) +  set('features', () => { +    return [] +  }) +  set('editMode', () => { +    return false +  }) +  set('component', () => { +    let props = { +      status: { +        policy: policy, +        features: features +      }, +      onCheckboxChange: ()=>{}, +      onDeleteJourneyPattern: ()=>{}, +      onOpenEditModal: ()=>{}, +      journeyPatterns: {}, +      value: { +        stop_points: [] +      }, +      index: 0, +      editMode: editMode +    } +    let list = renderer.create( +      <JourneyPattern +        status={props.status} +        journeyPatterns={props.journeyPatterns} +        value={props.value} +        index={props.index} +        onCheckboxChange={props.onCheckboxChange} +        onDeleteJourneyPattern={props.onDeleteJourneyPattern} +        onOpenEditModal={props.onOpenEditModal} +        editMode={props.editMode} +      /> +    ) + +    return list +  }) + + +  it('should display the show link', () => { +    expect(component.toJSON()).toMatchSnapshot() +    expect(component.root.findByProps({"data-target": "#JourneyPatternModal"})._fiber.stateNode.children[0].text).toEqual("Consulter") +  }) + +  context('in edit mode', () => { +    set('editMode', () => { +      return true +    }) + +    it('should display the edit link', () => { +      expect(component.toJSON()).toMatchSnapshot() +      expect(component.root.findByProps({"data-target": "#JourneyPatternModal"})._fiber.stateNode.children[0].text).toEqual("Editer") +    }) +  }) +}) diff --git a/spec/javascript/journey_patterns/components/__snapshots__/JourneyPattern_spec.js.snap b/spec/javascript/journey_patterns/components/__snapshots__/JourneyPattern_spec.js.snap new file mode 100644 index 000000000..0bedd8d69 --- /dev/null +++ b/spec/javascript/journey_patterns/components/__snapshots__/JourneyPattern_spec.js.snap @@ -0,0 +1,143 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`the edit button in edit mode should display the edit link 1`] = ` +<div +  className="t2e-item to_record" +> +  <div +    className="th" +  > +    <div +      className="strong mb-xs" +    > +      - +    </div> +    <div /> +    <div> +      0 +       arrĂȘt(s) +    </div> +    <div +      className="btn-group" +    > +      <div +        className="btn dropdown-toggle" +        data-toggle="dropdown" +      > +        <span +          className="fa fa-cog" +        /> +      </div> +      <ul +        className="dropdown-menu" +      > +        <li> +          <button +            data-target="#JourneyPatternModal" +            data-toggle="modal" +            onClick={[Function]} +            type="button" +          > +            Editer +          </button> +        </li> +        <li +          className="disabled" +        > +          <a +            href="blank/vehicle_journeys?jp=undefined" +          > +            Horaires des courses +          </a> +        </li> +        <li +          className="delete-action disabled" +        > +          <button +            className="disabled" +            disabled={true} +            onClick={[Function]} +            type="button" +          > +            <span +              className="fa fa-trash" +            /> +            Supprimer +          </button> +        </li> +      </ul> +    </div> +  </div> +</div> +`; + +exports[`the edit button should display the show link 1`] = ` +<div +  className="t2e-item to_record" +> +  <div +    className="th" +  > +    <div +      className="strong mb-xs" +    > +      - +    </div> +    <div /> +    <div> +      0 +       arrĂȘt(s) +    </div> +    <div +      className="btn-group" +    > +      <div +        className="btn dropdown-toggle" +        data-toggle="dropdown" +      > +        <span +          className="fa fa-cog" +        /> +      </div> +      <ul +        className="dropdown-menu" +      > +        <li> +          <button +            data-target="#JourneyPatternModal" +            data-toggle="modal" +            onClick={[Function]} +            type="button" +          > +            Consulter +          </button> +        </li> +        <li +          className="disabled" +        > +          <a +            href="blank/vehicle_journeys?jp=undefined" +          > +            Horaires des courses +          </a> +        </li> +        <li +          className="delete-action disabled" +        > +          <button +            className="disabled" +            disabled={true} +            onClick={[Function]} +            type="button" +          > +            <span +              className="fa fa-trash" +            /> +            Supprimer +          </button> +        </li> +      </ul> +    </div> +  </div> +</div> +`; | 
