aboutsummaryrefslogtreecommitdiffstats
path: root/spec/javascripts/journey_patterns
diff options
context:
space:
mode:
authorjpl2017-01-09 12:10:24 +0100
committerjpl2017-01-09 12:10:24 +0100
commit953fb3a48c43f5801bbc35dd02a2db26b21479b1 (patch)
tree2d42c8e5b59a6031f3100fac098ed2ff3e679cc9 /spec/javascripts/journey_patterns
parent7b57387a03a5f100320f91d7c8cb25e29d126815 (diff)
downloadchouette-core-953fb3a48c43f5801bbc35dd02a2db26b21479b1.tar.bz2
adding modal specs
Diffstat (limited to 'spec/javascripts/journey_patterns')
-rw-r--r--spec/javascripts/journey_patterns/reducers/modal_spec.js100
1 files changed, 100 insertions, 0 deletions
diff --git a/spec/javascripts/journey_patterns/reducers/modal_spec.js b/spec/javascripts/journey_patterns/reducers/modal_spec.js
new file mode 100644
index 000000000..ee83cb251
--- /dev/null
+++ b/spec/javascripts/journey_patterns/reducers/modal_spec.js
@@ -0,0 +1,100 @@
+var modalReducer = require('es6_browserified/journey_patterns/reducers/modal')
+
+let state = {}
+
+let fakeJourneyPattern = {
+ name: 'jp_test 1',
+ object_id: 'jp_test:JourneyPattern:1',
+ published_name: 'jp_test publishedname 1',
+ registration_number: 'jp_test registrationnumber 1',
+ stop_points: [],
+ deletable: false
+}
+
+const accept = cancel = function(){}
+
+describe('modal reducer', () => {
+ beforeEach(() => {
+ state = {
+ type: '',
+ modalProps: {},
+ confirmModal: {}
+ }
+ })
+
+ it('should return the initial state', () => {
+ expect(
+ modalReducer(undefined, {})
+ ).toEqual({})
+ })
+
+ it('should handle OPEN_CONFIRM_MODAL', () => {
+ let newState = Object.assign({}, state, {
+ type: 'confirm',
+ confirmModal: {
+ accept: accept,
+ cancel: cancel
+ }
+ })
+ expect(
+ modalReducer(state, {
+ type: 'OPEN_CONFIRM_MODAL',
+ accept,
+ cancel
+ })
+ ).toEqual(newState)
+ })
+
+ it('should handle EDIT_JOURNEYPATTERN_MODAL', () => {
+ let newState = Object.assign({}, state, {
+ type: 'edit',
+ modalProps: {
+ index: 0,
+ journeyPattern: fakeJourneyPattern
+ },
+ confirmModal: {}
+ })
+ expect(
+ modalReducer(state, {
+ type: 'EDIT_JOURNEYPATTERN_MODAL',
+ index: 0,
+ journeyPattern : fakeJourneyPattern
+ })
+ ).toEqual(newState)
+ })
+
+ it('should handle CREATE_JOURNEYPATTERN_MODAL', () => {
+ expect(
+ modalReducer(state, {
+ type: 'CREATE_JOURNEYPATTERN_MODAL'
+ })
+ ).toEqual(Object.assign({}, state, { type: 'create' }))
+ })
+
+ it('should handle DELETE_JOURNEYPATTERN', () => {
+ expect(
+ modalReducer(state, {
+ type: 'DELETE_JOURNEYPATTERN',
+ index: 0
+ })
+ ).toEqual(state)
+ })
+
+ it('should handle SAVE_MODAL', () => {
+ expect(
+ modalReducer(state, {
+ type: 'SAVE_MODAL',
+ index: 0,
+ data: {}
+ })
+ ).toEqual(state)
+ })
+
+ it('should handle CLOSE_MODAL', () => {
+ expect(
+ modalReducer(state, {
+ type: 'CLOSE_MODAL'
+ })
+ ).toEqual(state)
+ })
+})