diff options
| author | Alban Peignier | 2017-12-27 22:47:52 +0100 | 
|---|---|---|
| committer | GitHub | 2017-12-27 22:47:52 +0100 | 
| commit | 5826d342ae08b904ed23c45fd96066a348f04596 (patch) | |
| tree | 7879c1dd3a496fb90f45efdf0ac79f0881f0c953 /spec/javascript | |
| parent | b754b931eedfdd46a2ce32f1ca19683b6b79931c (diff) | |
| parent | 9854027e72c5084cc9183b1fc04816d7a914c1e5 (diff) | |
| download | chouette-core-5826d342ae08b904ed23c45fd96066a348f04596.tar.bz2 | |
Merge pull request #183 from af83/5407-add-purchase-windows-to-vehicle-journeys
Add purchase windows to vehicle journeys. Refs #5407
Diffstat (limited to 'spec/javascript')
3 files changed, 185 insertions, 1 deletions
| diff --git a/spec/javascript/vehicle_journeys/actions_spec.js b/spec/javascript/vehicle_journeys/actions_spec.js index 789507482..3af19ebc3 100644 --- a/spec/javascript/vehicle_journeys/actions_spec.js +++ b/spec/javascript/vehicle_journeys/actions_spec.js @@ -209,6 +209,13 @@ describe('when clicking on edit notes modal', () => {      expect(actions.openNotesEditModal(vehicleJourney)).toEqual(expectedAction)    })  }) + + //  ___ ___   ___ _____ _  _  ___ _____ ___ ___ + // | __/ _ \ / _ \_   _| \| |/ _ \_   _| __/ __| + // | _| (_) | (_) || | | .` | (_) || | | _|\__ \ + // |_| \___/ \___/ |_| |_|\_|\___/ |_| |___|___/ + // +  describe('when clicking on a footnote button inside footnote modal', () => {    it('should create an action to toggle this footnote', () => {      const footnote = {}, isShown = true @@ -230,6 +237,13 @@ describe('when clicking on validate button inside footnote modal', () => {      expect(actions.editVehicleJourneyNotes(footnotes)).toEqual(expectedAction)    })  }) + + //  _____ ___ __  __ ___ _____ _   ___ _    ___ ___ + // |_   _|_ _|  \/  | __|_   _/_\ | _ ) |  | __/ __| + //   | |  | || |\/| | _|  | |/ _ \| _ \ |__| _|\__ \ + //   |_| |___|_|  |_|___| |_/_/ \_\___/____|___|___/ + // +  describe('when clicking on calendar button in toolbox', () => {    it('should create an action to open calendar modal', () => {      const vehicleJourneys = [] @@ -288,6 +302,83 @@ describe('when using select2 to pick a timetable', () => {      expect(actions.selectTTCalendarsModal(selectedTT)).toEqual(expectedAction)    })  }) + + //  ___ _   _ ___  ___ _  _   _   ___ ___ + // | _ \ | | | _ \/ __| || | /_\ / __| __| + // |  _/ |_| |   / (__| __ |/ _ \\__ \ _| + // |_|  \___/|_|_\\___|_||_/_/_\_\___/___|__ + // \ \    / /_ _| \| |   \ / _ \ \    / / __| + //  \ \/\/ / | || .` | |) | (_) \ \/\/ /\__ \ + //   \_/\_/ |___|_|\_|___/ \___/ \_/\_/ |___/ + // + +describe('when clicking on purchase window button in toolbox', () => { +  it('should create an action to open purchase window modal', () => { +    const vehicleJourneys = [] +    const expectedAction = { +      type: 'EDIT_PURCHASE_WINDOWS_VEHICLEJOURNEY_MODAL', +      vehicleJourneys +    } +    expect(actions.openPurchaseWindowsEditModal(vehicleJourneys)).toEqual(expectedAction) +  }) +}) +describe('when clicking on delete button next to a purchase window inside modal', () => { +  it('should create an action to delete purchase window from selected vehicle journeys', () => { +    const purchaseWindow = {} +    const expectedAction = { +      type: 'DELETE_PURCHASE_WINDOW_MODAL', +      purchaseWindow +    } +    expect(actions.deletePurchaseWindowsModal(purchaseWindow)).toEqual(expectedAction) +  }) +}) +describe('when clicking on validate button inside purchase windows modal', () => { +  it('should create an action to update vj purchase windows', () => { +    const vehicleJourneys = [] +    const purchase_windows = [] +    const expectedAction = { +      type: 'EDIT_VEHICLEJOURNEYS_PURCHASE_WINDOWS', +      vehicleJourneys, +      purchase_windows +    } +    expect(actions.editVehicleJourneyPurchaseWindows(vehicleJourneys, purchase_windows)).toEqual(expectedAction) +  }) +}) +describe('when clicking on add button inside purchase windows modal', () => { +  it('should create an action to add the selected purchase window to preselected vjs', () => { +    const expectedAction = { +      type: 'ADD_SELECTED_PURCHASE_WINDOW', +    } +    expect(actions.addSelectedPurchaseWindow()).toEqual(expectedAction) +  }) +}) +describe('when using select2 to pick a purchase window', () => { +  it('should create an action to select a purchase window inside modal', () => { +    let selectedTT = { +      id: 1, +      objectid: 2, +      name: 'test', +      color: 'color', +    } +    const expectedAction = { +      type: 'SELECT_PURCHASE_WINDOW_MODAL', +      selectedItem:{ +        id: selectedTT.id, +        objectid: selectedTT.objectid, +        name: selectedTT.name, +        color: "color" +      } +    } +    expect(actions.selectPurchaseWindowsModal(selectedTT)).toEqual(expectedAction) +  }) +}) + + //  ___ ___ _  _____ ___ ___  ___ + // | __|_ _| ||_   _| __| _ \/ __| + // | _| | || |__| | | _||   /\__ \ + // |_| |___|____|_| |___|_|_\|___/ + // +  describe('when clicking on reset button inside query filters', () => {    it('should create an action to reset the query filters', () => {      const expectedAction = { diff --git a/spec/javascript/vehicle_journeys/reducers/modal_spec.js b/spec/javascript/vehicle_journeys/reducers/modal_spec.js index 69de9168b..ea8a002d2 100644 --- a/spec/javascript/vehicle_journeys/reducers/modal_spec.js +++ b/spec/javascript/vehicle_journeys/reducers/modal_spec.js @@ -91,6 +91,12 @@ describe('modal reducer', () => {      ).toEqual(newState)    }) +   //  _____ ___ __  __ ___ _____ _   ___ _    ___ ___ +   // |_   _|_ _|  \/  | __|_   _/_\ | _ ) |  | __/ __| +   //   | |  | || |\/| | _|  | |/ _ \| _ \ |__| _|\__ \ +   //   |_| |___|_|  |_|___| |_/_/ \_\___/____|___|___/ +   // +    it('should handle EDIT_CALENDARS_VEHICLEJOURNEY_MODAL', () => {      let vehicleJourneys = []      let modalPropsResult = { @@ -158,6 +164,82 @@ describe('modal reducer', () => {      ).toEqual(newState)    }) +  //  ___ _   _ ___  ___ _  _   _   ___ ___ +  // | _ \ | | | _ \/ __| || | /_\ / __| __| +  // |  _/ |_| |   / (__| __ |/ _ \\__ \ _| +  // |_|  \___/|_|_\\___|_||_/_/_\_\___/___|__ +  // \ \    / /_ _| \| |   \ / _ \ \    / / __| +  //  \ \/\/ / | || .` | |) | (_) \ \/\/ /\__ \ +  //   \_/\_/ |___|_|\_|___/ \___/ \_/\_/ |___/ +  // + +  it('should handle EDIT_PURCHASE_WINDOWS_VEHICLEJOURNEY_MODAL', () => { +    let vehicleJourneys = [] +    let modalPropsResult = { +      vehicleJourneys: [], +      purchase_windows: [] +    } +    expect( +      modalReducer(state, { +        type: 'EDIT_PURCHASE_WINDOWS_VEHICLEJOURNEY_MODAL', +        vehicleJourneys +      }) +    ).toEqual(Object.assign({}, state, {type: 'purchase_windows_edit', modalProps: modalPropsResult})) +  }) + +  it('should handle SELECT_PURCHASE_WINDOW_MODAL', () => { +    let newModalProps = {selectedPurchaseWindow : {id: 1}} +    expect( +      modalReducer(state, { +        type: 'SELECT_PURCHASE_WINDOW_MODAL', +        selectedItem: {id: 1} +      }) +    ).toEqual(Object.assign({}, state, {modalProps: newModalProps})) +  }) + +  it('should handle ADD_SELECTED_PURCHASE_WINDOW', () => { +    let fakeWindows = [{'test': 'test'}, {'test 2': 'test 2'}] +    let newWindows = [{'test': 'test'}, {'test 2': 'test 2'}, {'add': 'add'}] +    let fakeVehicleJourneys= [{purchase_windows: fakeWindows}, {purchase_windows: newWindows}] +    state.modalProps.vehicleJourneys = fakeVehicleJourneys +    state.modalProps.purchase_windows = fakeWindows +    state.modalProps.selectedPurchaseWindow = {'add': 'add'} +    let newState = { +      type: '', +      modalProps:{ +        vehicleJourneys: fakeVehicleJourneys, +        purchase_windows: [{'test': 'test'},{'test 2': 'test 2'},{'add': 'add'}], +        selectedPurchaseWindow: {'add': 'add'} +      }, +      confirmModal: {} +    } +    expect( +      modalReducer(state, { +        type: 'ADD_SELECTED_PURCHASE_WINDOW', +      }) +    ).toEqual(newState) +  }) + +  it('should handle DELETE_PURCHASE_WINDOW_MODAL', () => { +    let deletableWindow = {'delete': 'delete'} +    let fakeWindows = [{'test': 'test'}, {'test 2': 'test 2'}, deletableWindow] +    let newWindows = [{'test': 'test'}, {'test 2': 'test 2'}] +    let fakeVehicleJourneys= [{purchase_windows: fakeWindows}, {purchase_windows: newWindows}] +    state.modalProps = Object.assign({}, state.modalProps,{vehicleJourneys : fakeVehicleJourneys, purchase_windows: fakeWindows }) +    let newState = { +      // for the sake of the test, no need to specify the type +      type: '', +      modalProps:{vehicleJourneys: [{purchase_windows: newWindows},{purchase_windows: newWindows}], purchase_windows: newWindows}, +      confirmModal: {} +    } +    expect( +      modalReducer(state, { +        type: 'DELETE_PURCHASE_WINDOW_MODAL', +        purchaseWindow: deletableWindow +      }) +    ).toEqual(newState) +  }) +    it('should handle SELECT_CP_EDIT_MODAL', () => {      let newModalProps = {selectedCompany : {name: 'ALBATRANS'}}      expect( diff --git a/spec/javascript/vehicle_journeys/reducers/vehicleJourneys_spec.js b/spec/javascript/vehicle_journeys/reducers/vehicleJourneys_spec.js index 1c2cc1577..c834de1f6 100644 --- a/spec/javascript/vehicle_journeys/reducers/vehicleJourneys_spec.js +++ b/spec/javascript/vehicle_journeys/reducers/vehicleJourneys_spec.js @@ -254,7 +254,6 @@ describe('vehicleJourneys reducer', () => {      ).toEqual([newVJ, state[1]])    }) -    it('should handle EDIT_VEHICLEJOURNEYS_TIMETABLES', () => {      let newState = JSON.parse(JSON.stringify(state))      newState[0].time_tables = [fakeTimeTables[0]] @@ -266,4 +265,16 @@ describe('vehicleJourneys reducer', () => {        })      ).toEqual(newState)    }) + +  it('should handle EDIT_VEHICLEJOURNEYS_PURCHASE_WINDOWS', () => { +    let newState = JSON.parse(JSON.stringify(state)) +    newState[0].purchase_windows = [fakeTimeTables[0]] +    expect( +      vjReducer(state, { +        type: 'EDIT_VEHICLEJOURNEYS_PURCHASE_WINDOWS', +        vehicleJourneys: state, +        purchase_windows: [fakeTimeTables[0]] +      }) +    ).toEqual(newState) +  })  }) | 
