From c6f48a35ca41da95de0e3e10b893c297016ae8e7 Mon Sep 17 00:00:00 2001 From: Thomas Haddad Date: Fri, 6 Jan 2017 11:35:22 +0100 Subject: Move specs to separate directories Signed-off-by: Thomas Shawarma Haddad --- spec/javascripts/actions_spec.js | 71 -------- spec/javascripts/components_spec.js | 40 ----- spec/javascripts/itineraries/actions_spec.js | 71 ++++++++ spec/javascripts/itineraries/components_spec.js | 40 +++++ spec/javascripts/itineraries/reducers_spec.js | 178 +++++++++++++++++++++ spec/javascripts/journey_patterns/actions_spec.js | 0 spec/javascripts/journey_patterns/reducers_spec.js | 0 spec/javascripts/reducers_spec.js | 177 -------------------- 8 files changed, 289 insertions(+), 288 deletions(-) delete mode 100644 spec/javascripts/actions_spec.js delete mode 100644 spec/javascripts/components_spec.js create mode 100644 spec/javascripts/itineraries/actions_spec.js create mode 100644 spec/javascripts/itineraries/components_spec.js create mode 100644 spec/javascripts/itineraries/reducers_spec.js create mode 100644 spec/javascripts/journey_patterns/actions_spec.js create mode 100644 spec/javascripts/journey_patterns/reducers_spec.js delete mode 100644 spec/javascripts/reducers_spec.js (limited to 'spec/javascripts') diff --git a/spec/javascripts/actions_spec.js b/spec/javascripts/actions_spec.js deleted file mode 100644 index f86466375..000000000 --- a/spec/javascripts/actions_spec.js +++ /dev/null @@ -1,71 +0,0 @@ -var actions = require('es6_browserified/itineraries/actions') - -describe('actions', () => { - it('should create an action to add a stop', () => { - const expectedAction = { - type: 'ADD_STOP', - } - expect(actions.addStop()).toEqual(expectedAction) - }) -}) -describe('actions', () => { - it('should create an action to move up a stop', () => { - const index = 1 - const expectedAction = { - type: 'MOVE_STOP_UP', - index - } - expect(actions.moveStopUp(index)).toEqual(expectedAction) - }) -}) -describe('actions', () => { - it('should create an action to move down a stop', () => { - const index = 1 - const expectedAction = { - type: 'MOVE_STOP_DOWN', - index - } - expect(actions.moveStopDown(index)).toEqual(expectedAction) - }) -}) -describe('actions', () => { - it('should create an action to delete a stop', () => { - const index = 1 - const expectedAction = { - type: 'DELETE_STOP', - index - } - expect(actions.deleteStop(index)).toEqual(expectedAction) - }) -}) -describe('actions', () => { - it('should create an action to update the value of a stop', () => { - const text = 'updated text' - const index = 1 - const expectedAction = { - type: 'UPDATE_INPUT_VALUE', - index, - text - } - expect(actions.updateInputValue(index, text)).toEqual(expectedAction) - }) -}) - -describe('actions', () => { - it('should create an action to update the up select of a stop', () => { - const event = { - currentTarget: { - value: 'forbidden', - id: 'up' - } - } - const index = 1 - const expectedAction = { - type :'UPDATE_SELECT_VALUE', - select_id: 'up', - select_value: 'forbidden', - index - } - expect(actions.updateSelectValue(event, index)).toEqual(expectedAction) - }) -}) diff --git a/spec/javascripts/components_spec.js b/spec/javascripts/components_spec.js deleted file mode 100644 index c7e541783..000000000 --- a/spec/javascripts/components_spec.js +++ /dev/null @@ -1,40 +0,0 @@ -var React = require('react'); -var Provider = require('react-redux').Provider; -var actions = require('es6_browserified/itineraries/actions/index'); -var App = require('es6_browserified/itineraries/components/TodoList'); -var ConnectedApp = require('es6_browserified/itineraries/containers/VisibleTodoList'); -var TestUtils = require('react-addons-test-utils'); - -xdescribe('ConnectedApp', function() { - var connectedApp, store, initialItems; - var state; - state = [ - { - text: 'first', - index: 0, - for_boarding: 'normal', - for_alighting: 'normal' - }, - { - text: 'second', - index: 1, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - - beforeEach(function() { - store = state - }); - - describe('state provided by the store', function() { - beforeEach(function() { - connectedApp = TestUtils.renderIntoDocument(); - }); - - it('passes down items', function() { - app = TestUtils.findRenderedComponentWithType(connectedApp, App); - expect(app.props.items).toEqual(initialItems); - }); - }); -}); diff --git a/spec/javascripts/itineraries/actions_spec.js b/spec/javascripts/itineraries/actions_spec.js new file mode 100644 index 000000000..f86466375 --- /dev/null +++ b/spec/javascripts/itineraries/actions_spec.js @@ -0,0 +1,71 @@ +var actions = require('es6_browserified/itineraries/actions') + +describe('actions', () => { + it('should create an action to add a stop', () => { + const expectedAction = { + type: 'ADD_STOP', + } + expect(actions.addStop()).toEqual(expectedAction) + }) +}) +describe('actions', () => { + it('should create an action to move up a stop', () => { + const index = 1 + const expectedAction = { + type: 'MOVE_STOP_UP', + index + } + expect(actions.moveStopUp(index)).toEqual(expectedAction) + }) +}) +describe('actions', () => { + it('should create an action to move down a stop', () => { + const index = 1 + const expectedAction = { + type: 'MOVE_STOP_DOWN', + index + } + expect(actions.moveStopDown(index)).toEqual(expectedAction) + }) +}) +describe('actions', () => { + it('should create an action to delete a stop', () => { + const index = 1 + const expectedAction = { + type: 'DELETE_STOP', + index + } + expect(actions.deleteStop(index)).toEqual(expectedAction) + }) +}) +describe('actions', () => { + it('should create an action to update the value of a stop', () => { + const text = 'updated text' + const index = 1 + const expectedAction = { + type: 'UPDATE_INPUT_VALUE', + index, + text + } + expect(actions.updateInputValue(index, text)).toEqual(expectedAction) + }) +}) + +describe('actions', () => { + it('should create an action to update the up select of a stop', () => { + const event = { + currentTarget: { + value: 'forbidden', + id: 'up' + } + } + const index = 1 + const expectedAction = { + type :'UPDATE_SELECT_VALUE', + select_id: 'up', + select_value: 'forbidden', + index + } + expect(actions.updateSelectValue(event, index)).toEqual(expectedAction) + }) +}) diff --git a/spec/javascripts/itineraries/components_spec.js b/spec/javascripts/itineraries/components_spec.js new file mode 100644 index 000000000..c7e541783 --- /dev/null +++ b/spec/javascripts/itineraries/components_spec.js @@ -0,0 +1,40 @@ +var React = require('react'); +var Provider = require('react-redux').Provider; +var actions = require('es6_browserified/itineraries/actions/index'); +var App = require('es6_browserified/itineraries/components/TodoList'); +var ConnectedApp = require('es6_browserified/itineraries/containers/VisibleTodoList'); +var TestUtils = require('react-addons-test-utils'); + +xdescribe('ConnectedApp', function() { + var connectedApp, store, initialItems; + var state; + state = [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + + beforeEach(function() { + store = state + }); + + describe('state provided by the store', function() { + beforeEach(function() { + connectedApp = TestUtils.renderIntoDocument(); + }); + + it('passes down items', function() { + app = TestUtils.findRenderedComponentWithType(connectedApp, App); + expect(app.props.items).toEqual(initialItems); + }); + }); +}); diff --git a/spec/javascripts/itineraries/reducers_spec.js b/spec/javascripts/itineraries/reducers_spec.js new file mode 100644 index 000000000..d77500d3e --- /dev/null +++ b/spec/javascripts/itineraries/reducers_spec.js @@ -0,0 +1,178 @@ +var reducer = require('es6_browserified/itineraries/reducers/todos') +let state = [] +describe('stops reducer', () => { + beforeEach(()=>{ + state = [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + }) + + it('should return the initial state', () => { + expect( + reducer(undefined, {}) + ).toEqual([]) + }) + + it('should handle ADD_STOP', () => { + expect( + reducer(state, { + type: 'ADD_STOP' + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: '', + index: 2, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + it('should handle MOVE_UP_STOP', () => { + expect( + reducer(state, { + type: 'MOVE_STOP_UP', + index: 1 + }) + ).toEqual( + [ + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + it('should handle MOVE_DOWN_STOP', () => { + expect( + reducer(state, { + type: 'MOVE_STOP_DOWN', + index: 0 + }) + ).toEqual( + [ + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + it('should handle DELETE_STOP', () => { + expect( + reducer(state, { + type: 'DELETE_STOP', + index: 1 + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + //TODO unskip when es6 is properly functionnal + it('should handle UPDATE_INPUT_VALUE', () => { + expect( + reducer(state, { + type: 'UPDATE_INPUT_VALUE', + index: 0, + text: { + text: "new value", + stoparea_id: 1 + } + }) + ).toEqual( + [ + { + text: 'new value', + index: 0, + stoppoint_id: '', + stoparea_id: 1, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + it('should handle UPDATE_SELECT_VALUE', () => { + expect( + reducer(state, { + type :'UPDATE_SELECT_VALUE', + select_id: 'for_boarding', + select_value: 'prohibited', + index: 0 + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'prohibited', + for_alighting: 'normal' + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) +}) diff --git a/spec/javascripts/journey_patterns/actions_spec.js b/spec/javascripts/journey_patterns/actions_spec.js new file mode 100644 index 000000000..e69de29bb diff --git a/spec/javascripts/journey_patterns/reducers_spec.js b/spec/javascripts/journey_patterns/reducers_spec.js new file mode 100644 index 000000000..e69de29bb diff --git a/spec/javascripts/reducers_spec.js b/spec/javascripts/reducers_spec.js deleted file mode 100644 index 253229dda..000000000 --- a/spec/javascripts/reducers_spec.js +++ /dev/null @@ -1,177 +0,0 @@ -var reducer = require('es6_browserified/itineraries/reducers/todos') -let state = [] -describe('stops reducer', () => { - beforeEach(()=>{ - state = [ - { - text: 'first', - index: 0, - for_boarding: 'normal', - for_alighting: 'normal' - }, - { - text: 'second', - index: 1, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - }) - - it('should return the initial state', () => { - expect( - reducer(undefined, {}) - ).toEqual([]) - }) - - it('should handle ADD_STOP', () => { - expect( - reducer(state, { - type: 'ADD_STOP' - }) - ).toEqual( - [ - { - text: 'first', - index: 0, - for_boarding: 'normal', - for_alighting: 'normal' - }, - { - text: 'second', - index: 1, - for_boarding: 'normal', - for_alighting: 'normal' - }, - { - text: '', - index: 2, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - ) - }) - - it('should handle MOVE_UP_STOP', () => { - expect( - reducer(state, { - type: 'MOVE_STOP_UP', - index: 1 - }) - ).toEqual( - [ - { - text: 'second', - index: 1, - for_boarding: 'normal', - for_alighting: 'normal' - }, - { - text: 'first', - index: 0, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - ) - }) - - it('should handle MOVE_DOWN_STOP', () => { - expect( - reducer(state, { - type: 'MOVE_STOP_DOWN', - index: 0 - }) - ).toEqual( - [ - { - text: 'second', - index: 1, - for_boarding: 'normal', - for_alighting: 'normal' - }, - { - text: 'first', - index: 0, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - ) - }) - - it('should handle DELETE_STOP', () => { - expect( - reducer(state, { - type: 'DELETE_STOP', - index: 1 - }) - ).toEqual( - [ - { - text: 'first', - index: 0, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - ) - }) - - //TODO unskip when es6 is properly functionnal - it('should handle UPDATE_INPUT_VALUE', () => { - expect( - reducer(state, { - type: 'UPDATE_INPUT_VALUE', - index: 0, - text: { - text: "new value", - stoparea_id: 1 - } - }) - ).toEqual( - [ - { - text: 'new value', - index: 0, - stoparea_id: 1, - for_boarding: 'normal', - for_alighting: 'normal' - }, - { - text: 'second', - index: 1, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - ) - }) - - it('should handle UPDATE_SELECT_VALUE', () => { - expect( - reducer(state, { - type :'UPDATE_SELECT_VALUE', - select_id: 'for_boarding', - select_value: 'prohibited', - index: 0 - }) - ).toEqual( - [ - { - text: 'first', - index: 0, - for_boarding: 'prohibited', - for_alighting: 'normal' - }, - { - text: 'second', - index: 1, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - ) - }) -}) -- cgit v1.2.3