From bee0dd605e416833c680bdc9fafefbb5c1392ff6 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 25 Jan 2018 12:43:56 +0100 Subject: Refs #5598 @1h; Add specs --- .../components/JourneyPattern_spec.js | 63 +++++++++ .../__snapshots__/JourneyPattern_spec.js.snap | 143 +++++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100644 spec/javascript/journey_patterns/components/JourneyPattern_spec.js create mode 100644 spec/javascript/journey_patterns/components/__snapshots__/JourneyPattern_spec.js.snap (limited to 'spec/javascript') 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( + + ) + + 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`] = ` +
+
+
+ - +
+
+
+ 0 + arrĂȘt(s) +
+
+
+ +
+ +
+
+
+`; + +exports[`the edit button should display the show link 1`] = ` +
+
+
+ - +
+
+
+ 0 + arrĂȘt(s) +
+
+
+ +
+ +
+
+
+`; -- cgit v1.2.3