Skip to content

Commit

Permalink
Fix dates for monthly totals (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
argaen authored Oct 11, 2023
1 parent 2bca0b9 commit 5041ffe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 250 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"react-tailwindcss-datepicker": "^1.6.6",
"react-tooltip": "^5.21.5",
"reflect-metadata": "^0.1.13",
"sharp": "^0.32.6",
"simplebar-react": "^3.2.4",
"sql.js": "^1.8.0",
"swr": "^2.2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('MonthlyTotalHistogram', () => {
data: {
datasets: [],
labels: [
DateTime.fromISO('2022-05-01').startOf('day'),
DateTime.fromISO('2022-06-01').startOf('day'),
DateTime.fromISO('2022-07-01').startOf('day'),
DateTime.fromISO('2022-08-01').startOf('day'),
Expand Down Expand Up @@ -128,7 +129,7 @@ describe('MonthlyTotalHistogram', () => {
it.each([
undefined,
now.minus({ months: 3 }),
])('selects default date now - 8 months', (date) => {
])('selects default date now - 9 months', (date) => {
jest.spyOn(apiHook, 'useAccountsMonthlyTotals').mockReturnValue(
{
data: {
Expand Down Expand Up @@ -159,7 +160,8 @@ describe('MonthlyTotalHistogram', () => {
data: {
datasets: expect.any(Array),
labels: [
now.minus({ months: 7 }).startOf('month'),
now.minus({ months: 8 }).startOf('month'),
expect.any(DateTime),
expect.any(DateTime),
expect.any(DateTime),
expect.any(DateTime),
Expand All @@ -174,7 +176,7 @@ describe('MonthlyTotalHistogram', () => {
);
});

it('selects date range of 8 months in the past', () => {
it('selects date range of 9 months in the past', () => {
jest.spyOn(apiHook, 'useAccountsMonthlyTotals').mockReturnValue(
{
data: {
Expand Down Expand Up @@ -206,7 +208,8 @@ describe('MonthlyTotalHistogram', () => {
data: {
datasets: expect.any(Array),
labels: [
selectedDate.minus({ months: 3 }).startOf('month'),
selectedDate.minus({ months: 4 }).startOf('month'),
expect.any(DateTime),
expect.any(DateTime),
expect.any(DateTime),
expect.any(DateTime),
Expand Down Expand Up @@ -260,11 +263,11 @@ describe('MonthlyTotalHistogram', () => {
data: {
datasets: [
{
data: [-0, -0, -0, -0, -0, 1000, 1000, -0],
data: [-0, -0, -0, -0, -0, -0, 1000, 1000, -0],
label: 'Salary',
},
{
data: [-0, -0, -0, -0, -0, 150, 50, -0],
data: [-0, -0, -0, -0, -0, -0, 150, 50, -0],
label: 'Dividends',
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/accounts/MonthlyTotalHistogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function MonthlyTotalHistogram({
selectedDate = now.minus({ months: 4 });
}
const interval = Interval.fromDateTimes(
selectedDate.minus({ months: 4 }),
selectedDate.minus({ months: 5 }),
selectedDate.plus({ months: 4 }),
);

Expand Down
Loading

0 comments on commit 5041ffe

Please sign in to comment.