CASH-2572 | Update logic and unit tests
No dates should display if any of the props are missing
This commit is contained in:
parent
83f4c1dd4b
commit
85b8789bca
2 changed files with 8 additions and 11 deletions
|
|
@ -10,7 +10,7 @@ function mountDesktop(props = {}) {
|
||||||
value: 1024,
|
value: 1024,
|
||||||
});
|
});
|
||||||
return shallowMount(datePicker, {
|
return shallowMount(datePicker, {
|
||||||
props: { availableDates: AVAILABLE_DATES, modelValue: null, ...props },
|
props: { availableDates: AVAILABLE_DATES, startDate: "2026-01-21", endDate: "2026-01-25", modelValue: null, ...props },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ function mountMobile(props = {}) {
|
||||||
value: 375,
|
value: 375,
|
||||||
});
|
});
|
||||||
return shallowMount(datePicker, {
|
return shallowMount(datePicker, {
|
||||||
props: { availableDates: AVAILABLE_DATES, modelValue: null, ...props },
|
props: { availableDates: AVAILABLE_DATES, startDate: "2026-01-21", endDate: "2026-01-25", modelValue: null, ...props },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,7 +145,7 @@ describe("date-picker.vue", () => {
|
||||||
test("goForward advances windowStart by the window size", async () => {
|
test("goForward advances windowStart by the window size", async () => {
|
||||||
// Use a longer range so forward is possible on desktop (window 5)
|
// Use a longer range so forward is possible on desktop (window 5)
|
||||||
const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"];
|
const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"];
|
||||||
const wrapper = mountDesktop({ availableDates: manyDates });
|
const wrapper = mountDesktop({ availableDates: manyDates, startDate: "2026-01-01", endDate: "2026-01-10" });
|
||||||
expect(wrapper.vm.canGoForward).toBe(true);
|
expect(wrapper.vm.canGoForward).toBe(true);
|
||||||
await wrapper.vm.goForward();
|
await wrapper.vm.goForward();
|
||||||
expect(wrapper.vm.windowStart).toBe(5);
|
expect(wrapper.vm.windowStart).toBe(5);
|
||||||
|
|
@ -154,7 +154,7 @@ describe("date-picker.vue", () => {
|
||||||
|
|
||||||
test("goBack decrements windowStart by the window size", async () => {
|
test("goBack decrements windowStart by the window size", async () => {
|
||||||
const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"];
|
const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"];
|
||||||
const wrapper = mountDesktop({ availableDates: manyDates });
|
const wrapper = mountDesktop({ availableDates: manyDates, startDate: "2026-01-01", endDate: "2026-01-10" });
|
||||||
await wrapper.vm.goForward();
|
await wrapper.vm.goForward();
|
||||||
await wrapper.vm.goBack();
|
await wrapper.vm.goBack();
|
||||||
expect(wrapper.vm.windowStart).toBe(0);
|
expect(wrapper.vm.windowStart).toBe(0);
|
||||||
|
|
@ -181,7 +181,7 @@ describe("date-picker.vue", () => {
|
||||||
|
|
||||||
test("back button becomes enabled after navigating forward", async () => {
|
test("back button becomes enabled after navigating forward", async () => {
|
||||||
const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"];
|
const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"];
|
||||||
const wrapper = mountDesktop({ availableDates: manyDates });
|
const wrapper = mountDesktop({ availableDates: manyDates, startDate: "2026-01-01", endDate: "2026-01-10" });
|
||||||
await wrapper.vm.goForward();
|
await wrapper.vm.goForward();
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
const backBtn = wrapper.findAll(".date-picker__nav-btn")[0];
|
const backBtn = wrapper.findAll(".date-picker__nav-btn")[0];
|
||||||
|
|
|
||||||
|
|
@ -124,13 +124,10 @@ export default {
|
||||||
allDates() {
|
allDates() {
|
||||||
const availableSet = new Set(this.availableDates);
|
const availableSet = new Set(this.availableDates);
|
||||||
|
|
||||||
if (!this.availableDates.length) return [];
|
if (!this.availableDates.length || !this.startDate || !this.endDate) return [];
|
||||||
|
|
||||||
const startStr = this.startDate ?? this.availableDates[0];
|
const first = parseLocalDate(this.startDate);
|
||||||
const endStr = this.endDate ?? this.availableDates[this.availableDates.length - 1];
|
const last = parseLocalDate(this.endDate);
|
||||||
|
|
||||||
const first = parseLocalDate(startStr);
|
|
||||||
const last = parseLocalDate(endStr);
|
|
||||||
|
|
||||||
const dates = [];
|
const dates = [];
|
||||||
const cursor = new Date(first);
|
const cursor = new Date(first);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue