Skip to content

Commit

Permalink
test(frontend): handle new lines (#3977)
Browse files Browse the repository at this point in the history
# Motivation

Using Svelte v5 #3939 in tests renders the spaces as defined in the
component while in v4 we got just one.

```
- Expected
+ Received

- 0.22 BTC
+ 0.22
+ 		BTC
```

for

```
{formatToken({
			value: balance ?? ZERO,
			unitName: token.decimals,
			displayDecimals: token.decimals
})}
{token.symbol}
```

So we can split the expected results.
  • Loading branch information
peterpeterparker authored Dec 16, 2024
1 parent f095657 commit a7c515a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/frontend/src/tests/lib/components/send/SendSource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('SendSource', () => {
const balance: HTMLDivElement | null = container.querySelector(balanceSelector);

expect(source?.textContent).toBe('0xF2777205439a8c7be0425cbb21D8DB7426Df5DE9');
expect(balance?.textContent).toBe('0.22 BTC');
expect(balance?.textContent).toContain('0.22');
expect(balance?.textContent).toContain('BTC');
});
it('should render all field but balance without value', () => {
const { container } = render(SendSource, { ...props, token: undefined });
Expand All @@ -38,6 +39,7 @@ describe('SendSource', () => {
const balance: HTMLDivElement | null = container.querySelector(balanceSelector);

expect(source).toBeNull();
expect(balance?.textContent).toBe('0.22 BTC');
expect(balance?.textContent).toContain('0.22');
expect(balance?.textContent).toContain('BTC');
});
});

0 comments on commit a7c515a

Please sign in to comment.