mblabs-roccato-frontend-commons 0.2.17 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mblabs-roccato-frontend-commons",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20.11.1"
@@ -5,20 +5,25 @@ import { describe, it, expect, vi } from 'vitest';
5
5
  import { InputMoney } from './input-money';
6
6
 
7
7
  describe('<InputMoney />', () => {
8
- it('renders with default currency (BRL)', () => {
8
+ it('renders with default currency symbol and without select', () => {
9
9
  render(<InputMoney data-testid="money-input" />);
10
10
 
11
- const select = screen.getByTestId('currency-select');
12
- expect(select).toBeInTheDocument();
11
+ expect(screen.queryByTestId('currency-select')).not.toBeInTheDocument();
13
12
  expect(screen.getByText('R$')).toBeInTheDocument();
14
13
  });
15
14
 
16
- it('renders with custom default currency', () => {
15
+ it('falls back to BRL when default currency is unavailable', () => {
17
16
  render(<InputMoney defaultCurrency="USD" data-testid="money-input" />);
18
17
 
19
- const select = screen.getByTestId('currency-select');
20
- expect(select).toBeInTheDocument();
21
- expect(screen.getByText('$')).toBeInTheDocument();
18
+ expect(screen.queryByTestId('currency-select')).not.toBeInTheDocument();
19
+ expect(screen.getByText('R$')).toBeInTheDocument();
20
+ });
21
+
22
+ it('hides currency select when only one currency is available', () => {
23
+ render(<InputMoney availableCurrencies={[ 'BRL' ]} data-testid="money-input" />);
24
+
25
+ expect(screen.queryByTestId('currency-select')).not.toBeInTheDocument();
26
+ expect(screen.getByText('R$')).toBeInTheDocument();
22
27
  });
23
28
 
24
29
  it('calls onChange with minor units when amount changes', async () => {
@@ -57,10 +62,9 @@ describe('<InputMoney />', () => {
57
62
  render(<InputMoney disabled data-testid="money-input" />);
58
63
 
59
64
  const input = screen.getByTestId('money-input');
60
- const select = screen.getByTestId('currency-select');
61
65
 
62
66
  expect(input).toBeDisabled();
63
- expect(select).toBeDisabled();
67
+ expect(screen.queryByTestId('currency-select')).not.toBeInTheDocument();
64
68
  });
65
69
 
66
70
  it('applies different sizes correctly', () => {
@@ -85,11 +89,10 @@ describe('<InputMoney />', () => {
85
89
  expect(container).toHaveClass('border', 'border-gray-300', 'flex', 'w-full');
86
90
  });
87
91
 
88
- it('select has proper styling', () => {
92
+ it('does not render select trigger when only BRL is available', () => {
89
93
  render(<InputMoney data-testid="money-input" />);
90
94
 
91
- const select = screen.getByTestId('currency-select');
92
- expect(select).toHaveClass('flex', 'items-center', 'gap-1', 'bg-transparent');
95
+ expect(screen.queryByTestId('currency-select')).not.toBeInTheDocument();
93
96
  });
94
97
  });
95
98