Move settings data model refreshMetadata to sync calls (#9046)
In this PR, I'm - removing setting up the isAppWaitingForFreshMetadata boolean state in PageChangeEffect navigate (not robust) to some precise synchronous places, improving the control we have on when the app considers it's ready to be rendered based on fresh metadata - fixing tests
This commit is contained in:
@ -8,7 +8,7 @@ describe('getHighlightedDates', () => {
|
||||
expect(getHighlightedDates(dateRange)).toEqual([]);
|
||||
});
|
||||
|
||||
it('should should return empty if range is one day', () => {
|
||||
it('should should return one day if range is one day', () => {
|
||||
const dateRange = {
|
||||
start: new Date('2024-10-12T00:00:00.000Z'),
|
||||
end: new Date('2024-10-12T00:00:00.000Z'),
|
||||
@ -18,7 +18,7 @@ describe('getHighlightedDates', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should should return empty if range is 2 days', () => {
|
||||
it('should should return two days if range is 2 days', () => {
|
||||
const dateRange = {
|
||||
start: new Date('2024-10-12T00:00:00.000Z'),
|
||||
end: new Date('2024-10-13T00:00:00.000Z'),
|
||||
@ -29,7 +29,7 @@ describe('getHighlightedDates', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should should return empty if range is 10 days', () => {
|
||||
it('should should return 10 days if range is 10 days', () => {
|
||||
const dateRange = {
|
||||
start: new Date('2024-10-12T00:00:00.000Z'),
|
||||
end: new Date('2024-10-21T00:00:00.000Z'),
|
||||
@ -47,4 +47,12 @@ describe('getHighlightedDates', () => {
|
||||
new Date('2024-10-21T00:00:00.000Z'),
|
||||
]);
|
||||
});
|
||||
|
||||
it('should should return empty if range is 10 days but out of range', () => {
|
||||
const dateRange = {
|
||||
start: new Date('2023-10-01T00:00:00.000Z'),
|
||||
end: new Date('2023-10-10T00:00:00.000Z'),
|
||||
};
|
||||
expect(getHighlightedDates(dateRange)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@ -12,9 +12,11 @@ export const getHighlightedDates = (highlightedDateRange?: {
|
||||
const minDate = subMonths(currentDate, 2);
|
||||
const maxDate = addMonths(currentDate, 2);
|
||||
|
||||
let dateToHighlight = start < minDate ? minDate : start;
|
||||
const startDate = start < minDate ? minDate : start;
|
||||
const lastDate = end > maxDate ? maxDate : end;
|
||||
|
||||
let dateToHighlight = new Date(startDate);
|
||||
|
||||
while (dateToHighlight <= lastDate) {
|
||||
highlightedDates.push(dateToHighlight);
|
||||
dateToHighlight = addDays(dateToHighlight, 1);
|
||||
|
||||
Reference in New Issue
Block a user