aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZog2018-01-11 16:56:42 +0100
committerZog2018-01-11 16:56:42 +0100
commitf64486052cbe18730e9f0c68a625c34bbd7b53cd (patch)
tree7aea20e5d30993f8a6ebdc85a057f45950ec59ae
parented0faeaaa7bddc135c7b55f6d12fd09a739afacc (diff)
downloadchouette-core-f64486052cbe18730e9f0c68a625c34bbd7b53cd.tar.bz2
Add tests, but I'm unable to run them for now :-(
-rw-r--r--spec/javascript/vehicle_journeys/components/CustomFieldsInputs_spec.js42
-rw-r--r--spec/javascript/vehicle_journeys/components/__snapshots__/CustomFieldsInputs_spec.js.snap3
2 files changed, 45 insertions, 0 deletions
diff --git a/spec/javascript/vehicle_journeys/components/CustomFieldsInputs_spec.js b/spec/javascript/vehicle_journeys/components/CustomFieldsInputs_spec.js
new file mode 100644
index 000000000..62013354a
--- /dev/null
+++ b/spec/javascript/vehicle_journeys/components/CustomFieldsInputs_spec.js
@@ -0,0 +1,42 @@
+import React, { Component } from 'react'
+import CustomFieldsInputs from '../../../../app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs'
+import renderer from 'react-test-renderer'
+require('select2')
+console.log($().jquery)
+
+describe('CustomFieldsInputs', () => {
+ set('values', () => {
+ return {}
+ })
+
+ set('component', () => {
+ let inputs = renderer.create(
+ <CustomFieldsInputs
+ values={values}
+ disabled={false}
+ onUpdate={()=>{}}
+ />
+ ).toJSON()
+
+ return inputs
+ })
+
+ it('should match the snapshot', () => {
+ expect(component).toMatchSnapshot()
+ })
+
+ context('with fields', () => {
+ set('values', () => {
+ return {
+ foo: {
+ options: { list_values: ["", "1", "2"] },
+ field_type: "list",
+ name: "test"
+ }
+ }
+ })
+ it('should match the snapshot', () => {
+ expect(component).toMatchSnapshot()
+ })
+ })
+})
diff --git a/spec/javascript/vehicle_journeys/components/__snapshots__/CustomFieldsInputs_spec.js.snap b/spec/javascript/vehicle_journeys/components/__snapshots__/CustomFieldsInputs_spec.js.snap
new file mode 100644
index 000000000..c93ec0097
--- /dev/null
+++ b/spec/javascript/vehicle_journeys/components/__snapshots__/CustomFieldsInputs_spec.js.snap
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`CustomFieldsInputs should match the snapshot 1`] = `<div />`;