fb3cf94cba
Fix setting the new reminder component to null after adding a new date Add "close on change" event which only fires if the component closed and the value actually changed Hide the "today" option after 21:00 Add "confirm" button to close the component Use disabled in reminders Add a disabled property to the datepicker Cleanup workarounds for flatpickr Use the new datepicker for end dates Use the new datepicker for start date Use the new datepicker for due dates Mobile styling Format Sync flatpickr when clicking on choose a date Make sure to only hide the popup when not clicked something inside of it Make flatpickr dates work Use datepicker component for reminders Merge branch 'master' into feature/better-reminders Fix bottom padding of inline flatpickr Set time Add method to calculate the neares time Move time helpers in separate folder Remove separate flatpickr date Cleanup Set the flatpickr date when setting changing the date Better formatting of the chosen date Bubble Set date when choosing one Fix test Show correct weekday in preview Change hover background color Make label to show if selected date is null configurable Use a different icon for weekend Ignore test files when linting Add tests to dron Move day interval calculation to separate file and test it Add next date calculation Add basic date picker component Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/308 Co-Authored-By: konrad <konrad@kola-entertainments.de> Co-Committed-By: konrad <konrad@kola-entertainments.de>
93 lines
No EOL
1.9 KiB
JavaScript
93 lines
No EOL
1.9 KiB
JavaScript
import {calculateDayInterval} from './calculateDayInterval'
|
|
|
|
const days = {
|
|
monday: 1,
|
|
tuesday: 2,
|
|
wednesday: 3,
|
|
thursday: 4,
|
|
friday: 5,
|
|
saturday: 6,
|
|
sunday: 0,
|
|
}
|
|
|
|
for (const n in days) {
|
|
test(`today on a ${n}`, () => {
|
|
expect(calculateDayInterval('today', days[n])).toBe(0)
|
|
})
|
|
}
|
|
|
|
for (const n in days) {
|
|
test(`tomorrow on a ${n}`, () => {
|
|
expect(calculateDayInterval('tomorrow', days[n])).toBe(1)
|
|
})
|
|
}
|
|
|
|
const nextMonday = {
|
|
monday: 0,
|
|
tuesday: 6,
|
|
wednesday: 5,
|
|
thursday: 4,
|
|
friday: 3,
|
|
saturday: 2,
|
|
sunday: 1,
|
|
}
|
|
|
|
for (const n in nextMonday) {
|
|
test(`next monday on a ${n}`, () => {
|
|
expect(calculateDayInterval('nextMonday', days[n])).toBe(nextMonday[n])
|
|
})
|
|
}
|
|
|
|
const thisWeekend = {
|
|
monday: 5,
|
|
tuesday: 4,
|
|
wednesday: 3,
|
|
thursday: 2,
|
|
friday: 1,
|
|
saturday: 0,
|
|
sunday: 0,
|
|
}
|
|
|
|
for (const n in thisWeekend) {
|
|
test(`this weekend on a ${n}`, () => {
|
|
expect(calculateDayInterval('thisWeekend', days[n])).toBe(thisWeekend[n])
|
|
})
|
|
}
|
|
|
|
const laterThisWeek = {
|
|
monday: 2,
|
|
tuesday: 2,
|
|
wednesday: 2,
|
|
thursday: 2,
|
|
friday: 0,
|
|
saturday: 0,
|
|
sunday: 0,
|
|
}
|
|
|
|
for (const n in laterThisWeek) {
|
|
test(`later this week on a ${n}`, () => {
|
|
expect(calculateDayInterval('laterThisWeek', days[n])).toBe(laterThisWeek[n])
|
|
})
|
|
}
|
|
|
|
const laterNextWeek = {
|
|
monday: 7 + 2,
|
|
tuesday: 7 + 2,
|
|
wednesday: 7 + 2,
|
|
thursday: 7 + 2,
|
|
friday: 7 + 0,
|
|
saturday: 7 + 0,
|
|
sunday: 7 + 0,
|
|
}
|
|
|
|
for (const n in laterNextWeek) {
|
|
test(`later next week on a ${n} (this week)`, () => {
|
|
expect(calculateDayInterval('laterNextWeek', days[n])).toBe(laterNextWeek[n])
|
|
})
|
|
}
|
|
|
|
for (const n in days) {
|
|
test(`next week on a ${n}`, () => {
|
|
expect(calculateDayInterval('nextWeek', days[n])).toBe(7)
|
|
})
|
|
} |