Skip to content

Commit c2e3931

Browse files
committed
refactor: add missed scenarios for inputs
1 parent 2e3ec67 commit c2e3931

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

setup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import '@testing-library/react-native/extend-expect';
21
// react-hook form setup for testing
32
// @ts-ignore
43
global.window = {};

src/ui/button.test.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable max-lines-per-function */
22
import React from 'react';
3+
import { Text } from 'react-native';
34

45
import { cleanup, fireEvent, render, screen } from '@/core/test-utils';
56

@@ -9,9 +10,17 @@ afterEach(cleanup);
910

1011
describe('Button component ', () => {
1112
it('should render correctly ', () => {
12-
render(<Button testID="button" disabled={false} />);
13+
render(<Button testID="button" />);
1314
expect(screen.getByTestId('button')).toBeOnTheScreen();
1415
});
16+
it('should render correctly if we add explicit child ', () => {
17+
render(
18+
<Button testID="button">
19+
<Text> Custom child </Text>
20+
</Button>
21+
);
22+
expect(screen.getByText('Custom child')).toBeOnTheScreen();
23+
});
1524
it('should render the label correctly', () => {
1625
render(<Button testID="button" label="Submit" />);
1726
expect(screen.getByTestId('button')).toBeOnTheScreen();

src/ui/input.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable max-lines-per-function */
22
import React from 'react';
3+
import { I18nManager } from 'react-native';
34

45
import { cleanup, fireEvent, render, screen } from '@/core/test-utils';
56

@@ -12,6 +13,21 @@ describe('Input component ', () => {
1213
render(<Input testID="input" />);
1314
expect(screen.getByTestId('input')).toBeOnTheScreen();
1415
});
16+
it('should use the right direction for rtl layout', () => {
17+
I18nManager.isRTL = true;
18+
render(<Input testID="input" />);
19+
expect(screen.getByTestId('input')).toHaveStyle({
20+
writingDirection: 'rtl',
21+
});
22+
});
23+
24+
it('should use the right direction for ltr layout', () => {
25+
I18nManager.isRTL = false;
26+
render(<Input testID="input" />);
27+
expect(screen.getByTestId('input')).toHaveStyle({
28+
writingDirection: 'ltr',
29+
});
30+
});
1531

1632
it('should render the placeholder correctly ', () => {
1733
render(<Input testID="input" placeholder="Enter your username" />);

0 commit comments

Comments
 (0)