Skip to content

Commit

Permalink
Patch unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored and joel-jeremy committed Apr 13, 2024
1 parent ddebeb7 commit a8dd511
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ function CategoryItem({
>
{isToBeBudgetedItem
? toBudget != null
? integerToCurrency(toBudget || 0)
? ` ${integerToCurrency(toBudget || 0)}`
: null
: balance != null
? integerToCurrency(balance || 0)
? ` ${integerToCurrency(balance || 0)}`
: null}
</TextOneLine>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import userEvent from '@testing-library/user-event';
import { format as formatDate, parse as parseDate } from 'date-fns';
import { v4 as uuidv4 } from 'uuid';

import { SpreadsheetProvider } from 'loot-core/src/client/SpreadsheetProvider';
import {
generateTransaction,
generateAccount,
Expand Down Expand Up @@ -118,26 +119,28 @@ function LiveTransactionTable(props) {
return (
<TestProvider>
<ResponsiveProvider>
<SelectedProviderWithItems
name="transactions"
items={transactions}
fetchAllIds={() => transactions.map(t => t.id)}
>
<SplitsExpandedProvider>
<TransactionTable
{...props}
transactions={transactions}
loadMoreTransactions={() => {}}
payees={payees}
addNotification={n => console.log(n)}
onSave={onSave}
onSplit={onSplit}
onAdd={onAdd}
onAddSplit={onAddSplit}
onCreatePayee={onCreatePayee}
/>
</SplitsExpandedProvider>
</SelectedProviderWithItems>
<SpreadsheetProvider>
<SelectedProviderWithItems
name="transactions"
items={transactions}
fetchAllIds={() => transactions.map(t => t.id)}
>
<SplitsExpandedProvider>
<TransactionTable
{...props}
transactions={transactions}
loadMoreTransactions={() => {}}
payees={payees}
addNotification={n => console.log(n)}
onSave={onSave}
onSplit={onSplit}
onAdd={onAdd}
onAddSplit={onAddSplit}
onCreatePayee={onCreatePayee}
/>
</SplitsExpandedProvider>
</SelectedProviderWithItems>
</SpreadsheetProvider>
</ResponsiveProvider>
</TestProvider>
);
Expand All @@ -155,6 +158,9 @@ function initBasicServer() {
throw new Error(`queried unknown table: ${query.table}`);
}
},
getCell: () => ({
value: 129_87,
}),
});
}

Expand Down Expand Up @@ -447,7 +453,7 @@ describe('Transactions', () => {
let items = tooltip.querySelectorAll('[data-testid*="category-item"]');
expect(items.length).toBe(2);
expect(items[0].textContent).toBe('Usual Expenses');
expect(items[1].textContent).toBe('General');
expect(items[1].textContent).toBe('General 129.87');
expect(items[1].dataset['highlighted']).toBeDefined();

// It should not allow filtering on group names
Expand All @@ -473,7 +479,7 @@ describe('Transactions', () => {
// The right item should be highlighted
highlighted = tooltip.querySelector('[data-highlighted]');
expect(highlighted).not.toBeNull();
expect(highlighted.textContent).toBe('General');
expect(highlighted.textContent).toBe('General 129.87');

expect(getTransactions()[2].category).toBe(
categories.find(category => category.name === 'Food').id,
Expand Down Expand Up @@ -515,7 +521,7 @@ describe('Transactions', () => {
// Make sure the expected category is highlighted
highlighted = tooltip.querySelector('[data-highlighted]');
expect(highlighted).not.toBeNull();
expect(highlighted.textContent).toBe('General');
expect(highlighted.textContent).toBe('General 129.87');

// Click the item and check the before/after values
expect(getTransactions()[2].category).toBe(
Expand Down

0 comments on commit a8dd511

Please sign in to comment.