-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix reservationsMinDaysBefore initialization when reservationsMaxDays…
…Before is set (#376)
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
admin-ui/src/component/ReservationUnits/ReservationUnitEditor/reducer.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters