diff --git a/src/__tests__/components/charts/Pie.test.tsx b/src/__tests__/components/charts/Pie.test.tsx
index 8e06a875..620d1a18 100644
--- a/src/__tests__/components/charts/Pie.test.tsx
+++ b/src/__tests__/components/charts/Pie.test.tsx
@@ -32,11 +32,7 @@ describe('Pie', () => {
borderWidth: 0,
},
},
- plugins: {
- autocolors: {
- mode: 'data',
- },
- },
+ plugins: {},
},
type: 'doughnut',
},
@@ -73,9 +69,6 @@ describe('Pie', () => {
title: {
display: true,
},
- autocolors: {
- mode: 'data',
- },
},
},
type: 'doughnut',
diff --git a/src/__tests__/components/charts/TotalsPie.test.tsx b/src/__tests__/components/charts/TotalsPie.test.tsx
index e3d4f7d7..5e8df48c 100644
--- a/src/__tests__/components/charts/TotalsPie.test.tsx
+++ b/src/__tests__/components/charts/TotalsPie.test.tsx
@@ -77,6 +77,10 @@ describe('TotalsPie', () => {
label: expect.any(Function),
},
},
+ autocolors: {
+ mode: 'data',
+ enabled: false,
+ },
},
},
},
@@ -147,6 +151,14 @@ describe('TotalsPie', () => {
],
labels: ['Assets', 'Liabilities'],
},
+ options: expect.objectContaining({
+ plugins: expect.objectContaining({
+ autocolors: {
+ mode: 'data',
+ enabled: true,
+ },
+ }),
+ }),
}),
undefined,
);
diff --git a/src/__tests__/components/pages/account/IEInfo.test.tsx b/src/__tests__/components/pages/account/IEInfo.test.tsx
index 1e782f2f..aef0fef3 100644
--- a/src/__tests__/components/pages/account/IEInfo.test.tsx
+++ b/src/__tests__/components/pages/account/IEInfo.test.tsx
@@ -51,38 +51,43 @@ describe('IEInfo', () => {
,
);
- expect(MonthlyTotalHistogram).toBeCalledWith(
+ expect(MonthlyTotalHistogram).toHaveBeenCalledWith(
{
guids: [account.guid],
title: '',
},
undefined,
);
- expect(TotalWidget).toBeCalledWith(
+ expect(TotalWidget).toHaveBeenCalledWith(
{ account },
undefined,
);
expect(container).toMatchSnapshot();
});
- it('renders as expected when placeholder', () => {
+ it.each([
+ ['INCOME', 'Total earned'],
+ ['EXPENSE', 'Total spent'],
+ ['EQUITY', 'Total'],
+ ])('renders as expected when placeholder with %s', (type, title) => {
account.placeholder = true;
account.childrenIds = ['1', '2'];
+ account.type = type;
const { container } = render(
,
);
- expect(AccountsTable).toBeCalledWith({ guids: ['1', '2'] }, undefined);
- expect(TotalsPie).toBeCalledWith(
+ expect(AccountsTable).toHaveBeenCalledWith({ guids: ['1', '2'] }, undefined);
+ expect(TotalsPie).toHaveBeenCalledWith(
{
guids: ['1', '2'],
showDataLabels: false,
showTooltip: true,
- title: 'Total spent',
+ title,
},
undefined,
);
- expect(MonthlyTotalHistogram).toBeCalledWith(
+ expect(MonthlyTotalHistogram).toHaveBeenCalledWith(
{
guids: ['1', '2'],
title: '',
diff --git a/src/__tests__/components/pages/account/__snapshots__/IEInfo.test.tsx.snap b/src/__tests__/components/pages/account/__snapshots__/IEInfo.test.tsx.snap
index 1ced2cd0..f67f1349 100644
--- a/src/__tests__/components/pages/account/__snapshots__/IEInfo.test.tsx.snap
+++ b/src/__tests__/components/pages/account/__snapshots__/IEInfo.test.tsx.snap
@@ -37,7 +37,95 @@ exports[`IEInfo renders as expected when not placeholder 1`] = `
`;
-exports[`IEInfo renders as expected when placeholder 1`] = `
+exports[`IEInfo renders as expected when placeholder with EQUITY 1`] = `
+
+`;
+
+exports[`IEInfo renders as expected when placeholder with EXPENSE 1`] = `
+
+`;
+
+exports[`IEInfo renders as expected when placeholder with INCOME 1`] = `
= {
borderWidth: 0,
},
},
- plugins: {
- autocolors: {
- mode: 'data',
- },
- },
};
export default function Doughnut({
diff --git a/src/components/charts/TotalsPie.tsx b/src/components/charts/TotalsPie.tsx
index fa64b57d..f387db41 100644
--- a/src/components/charts/TotalsPie.tsx
+++ b/src/components/charts/TotalsPie.tsx
@@ -94,6 +94,10 @@ export default function TotalsPie({
),
padding: 6,
},
+ autocolors: {
+ mode: 'data',
+ enabled: (backgroundColor?.length || 0) > 0,
+ },
},
}}
/>
diff --git a/src/components/pages/account/IEInfo.tsx b/src/components/pages/account/IEInfo.tsx
index bb65a900..a25f7b2f 100644
--- a/src/components/pages/account/IEInfo.tsx
+++ b/src/components/pages/account/IEInfo.tsx
@@ -28,7 +28,7 @@ export default function IEInfo({
&& (
<>
);
}
+
+function getTitle(type: string): string {
+ if (type === 'INCOME') {
+ return 'Total earned';
+ }
+
+ if (type === 'EXPENSE') {
+ return 'Total spent';
+ }
+
+ return 'Total';
+}