aboutsummaryrefslogtreecommitdiffstats
path: root/spec/javascripts
diff options
context:
space:
mode:
authorXinhui2017-02-27 10:35:23 +0100
committerXinhui2017-02-27 10:35:23 +0100
commitdd6c19075007302c1ccf33a3e94a98162c721d62 (patch)
tree10883d001af4675096a4c5ecc6326c37da1bb49a /spec/javascripts
parenta382f7c0094d15abbc21baf7a7eaabcec9545f72 (diff)
parent691862d5c42504002c113c9b493f78583d08b83d (diff)
downloadchouette-core-dd6c19075007302c1ccf33a3e94a98162c721d62.tar.bz2
Merge branch 'master' into staging
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/itineraries/components_spec.js53
-rw-r--r--spec/javascripts/itineraries/reducers/stop_points_spec.js68
2 files changed, 64 insertions, 57 deletions
diff --git a/spec/javascripts/itineraries/components_spec.js b/spec/javascripts/itineraries/components_spec.js
deleted file mode 100644
index 24ead7b5d..000000000
--- a/spec/javascripts/itineraries/components_spec.js
+++ /dev/null
@@ -1,53 +0,0 @@
-var React = require('react');
-var shallow = require('enzyme').shallow;
-var mount = require('enzyme').mount;
-var StopPointList = require('es6_browserified/itineraries/components/StopPointList');
-var StopPoint = require('es6_browserified/itineraries/components/StopPoint');
-var sinon = require('sinon')
-
-describe('(Component) StopPointList', () => {
- it('renders without exploding', () => {
- const wrapper = shallow(<StopPointList
- stopPoints = {[]}
- onChange = {() => {}}
- onMoveDownClick={() => {}}
- onMoveUpClick={() => {}}
- onDeleteClick={() => {}}
- onSelectChange={() => {}}
- onSelectMarker={() => {}}
- onUnselectMarker={() => {}}
- />);
- expect(wrapper.length).toEqual(1);
- });
-
- it('simulates click events', () => {
- const state = {
- text: 'first',
- index: 0,
- for_boarding: 'normal',
- for_alighting: 'normal',
- user_objectid: '',
- olMap: {
- isOpened: false,
- json: {}
- }
- }
- const onButtonClick = sinon.spy();
- const wrapper = mount(<StopPoint
- value = {state}
- onChange = {() => {}}
- onMoveDownClick={() => {}}
- onMoveUpClick={() => {}}
- onDeleteClick={onButtonClick}
- onSelectChange={() => {}}
- onSelectMarker={() => {}}
- onToggleMap={() => {}}
- onUnselectMarker={() => {}}
- first= {true}
- last= {true}
- index= {0}
- />);
- wrapper.find('.delete').simulate('click');
- expect(onButtonClick.calledOnce).toEqual(true);
- });
-});
diff --git a/spec/javascripts/itineraries/reducers/stop_points_spec.js b/spec/javascripts/itineraries/reducers/stop_points_spec.js
index d6917f782..adbf77aa1 100644
--- a/spec/javascripts/itineraries/reducers/stop_points_spec.js
+++ b/spec/javascripts/itineraries/reducers/stop_points_spec.js
@@ -16,6 +16,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -26,6 +27,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -52,6 +54,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -62,6 +65,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -72,6 +76,7 @@ describe('stops reducer', () => {
{
text: '',
index: 2,
+ edit: true,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -94,6 +99,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -104,6 +110,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -126,6 +133,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -136,6 +144,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -158,6 +167,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -174,6 +184,7 @@ describe('stops reducer', () => {
stopPointsReducer(state, {
type: 'UPDATE_INPUT_VALUE',
index: 0,
+ edit: false,
text: {
text: "new value",
name: 'new',
@@ -190,6 +201,7 @@ describe('stops reducer', () => {
text: 'new value',
name: 'new',
index: 0,
+ edit: false,
stoppoint_id: '',
stoparea_id: 1,
for_boarding: 'normal',
@@ -206,6 +218,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -220,16 +233,17 @@ describe('stops reducer', () => {
it('should handle UPDATE_SELECT_VALUE', () => {
expect(
stopPointsReducer(state, {
- type :'UPDATE_SELECT_VALUE',
- select_id: 'for_boarding',
- select_value: 'prohibited',
- index: 0
+ type :'UPDATE_SELECT_VALUE',
+ select_id: 'for_boarding',
+ select_value: 'prohibited',
+ index: 0
})
).toEqual(
[
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'prohibited',
for_alighting: 'normal',
olMap: {
@@ -240,6 +254,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -262,6 +277,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -269,6 +285,7 @@ describe('stops reducer', () => {
json: {
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: undefined
@@ -278,6 +295,41 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
+ for_boarding: 'normal',
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
+ }
+ ]
+ )
+ })
+
+ it('should handle TOGGLE_EDIT', () => {
+ expect(
+ stopPointsReducer(state, {
+ type: 'TOGGLE_EDIT',
+ index: 0
+ })
+ ).toEqual(
+ [
+ {
+ text: 'first',
+ index: 0,
+ edit: true,
+ for_boarding: 'normal',
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
+ },
+ {
+ text: 'second',
+ index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -294,6 +346,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -304,6 +357,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -323,6 +377,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -333,6 +388,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -349,6 +405,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -359,6 +416,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -378,6 +436,7 @@ describe('stops reducer', () => {
{
text: 'first',
index: 0,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {
@@ -388,6 +447,7 @@ describe('stops reducer', () => {
{
text: 'second',
index: 1,
+ edit: false,
for_boarding: 'normal',
for_alighting: 'normal',
olMap: {