Skip to content

Commit

Permalink
fix reservationsMinDaysBefore initialization when reservationsMaxDays…
Browse files Browse the repository at this point in the history
…Before is set (#376)
  • Loading branch information
siren authored Aug 24, 2022
1 parent 6aafd77 commit e2227b6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { reducer } from "./reducer";
import { State } from "./types";

test("minDaysBefore is zeroed if it does not exist", () => {
const state = {
reservationUnitEdit: {},
} as unknown as State;

expect(
reducer(state, {
type: "setReservationsMaxDaysBefore",
reservationsMaxDaysBefore: 10,
}).reservationUnitEdit.reservationsMinDaysBefore
).toEqual(0);
});

test("minDaysBefore is capped if it exists", () => {
const state = {
reservationUnitEdit: { reservationsMinDaysBefore: 20 },
} as unknown as State;

expect(
reducer(state, {
type: "setReservationsMaxDaysBefore",
reservationsMaxDaysBefore: 10,
}).reservationUnitEdit.reservationsMinDaysBefore
).toEqual(10);
});
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export const reducer = (state: State, action: Action): State => {
action.reservationsMaxDaysBefore,
state.reservationUnitEdit.reservationsMinDaysBefore
)
: undefined,
: 0,
});
}
case "setSpaces": {
Expand Down

0 comments on commit e2227b6

Please sign in to comment.