CASH-2572 | Unit test and logic updates
This commit is contained in:
parent
44821ce536
commit
83f4c1dd4b
2 changed files with 10 additions and 24 deletions
|
|
@ -61,14 +61,6 @@ describe("date-picker.vue", () => {
|
|||
expect(backBtn.attributes("disabled")).toBeDefined();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test("forward navigation button is disabled when all dates fit in window", () => {
|
||||
// Only 2 available dates → range is 2 days, window size 5 → no forward
|
||||
const wrapper = mountDesktop({ availableDates: ["2026-01-21", "2026-01-22"] });
|
||||
const forwardBtn = wrapper.findAll(".date-picker__nav-btn")[1];
|
||||
expect(forwardBtn.attributes("disabled")).toBeDefined();
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allDates computation", () => {
|
||||
|
|
@ -196,16 +188,6 @@ describe("date-picker.vue", () => {
|
|||
expect(backBtn.attributes("disabled")).toBeUndefined();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test("resets windowStart to 0 when availableDates prop changes", async () => {
|
||||
const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"];
|
||||
const wrapper = mountDesktop({ availableDates: manyDates });
|
||||
await wrapper.vm.goForward();
|
||||
expect(wrapper.vm.windowStart).toBeGreaterThan(0);
|
||||
await wrapper.setProps({ availableDates: ["2026-02-01", "2026-02-02"] });
|
||||
expect(wrapper.vm.windowStart).toBe(0);
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
describe("initial window positioning", () => {
|
||||
|
|
|
|||
|
|
@ -114,19 +114,23 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
windowStart: 0,
|
||||
windowSize: DESKTOP_WINDOW_SIZE,
|
||||
windowSize:
|
||||
window.innerWidth >= DESKTOP_BREAKPOINT_PX
|
||||
? DESKTOP_WINDOW_SIZE
|
||||
: MOBILE_WINDOW_SIZE,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
allDates() {
|
||||
const availableSet = new Set(this.availableDates);
|
||||
|
||||
const hasBounds = this.startDate && this.endDate;
|
||||
const hasAvailable = this.availableDates.length > 0;
|
||||
if (!hasBounds || !hasAvailable) return [];
|
||||
if (!this.availableDates.length) return [];
|
||||
|
||||
const first = parseLocalDate(this.startDate);
|
||||
const last = parseLocalDate(this.endDate);
|
||||
const startStr = this.startDate ?? this.availableDates[0];
|
||||
const endStr = this.endDate ?? this.availableDates[this.availableDates.length - 1];
|
||||
|
||||
const first = parseLocalDate(startStr);
|
||||
const last = parseLocalDate(endStr);
|
||||
|
||||
const dates = [];
|
||||
const cursor = new Date(first);
|
||||
|
|
|
|||
Loading…
Reference in a new issue