Skip to content

Commit

Permalink
feat: rename Text to Translation
Browse files Browse the repository at this point in the history
  • Loading branch information
pret-a-porter committed Nov 18, 2024
1 parent f689960 commit e1e5537
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
10 changes: 5 additions & 5 deletions packages/react/src/__tests__/html.test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { render } from '@testing-library/react';
import * as React from 'react';
import { Numeric, Text } from '../components';
import { Translation } from '../components';
import { TestWrapper } from './test_wrapper';

describe('EOLocaleHtml', () => {
it('Should wrap in span by default', () => {
const { getByTestId } = render(
<TestWrapper>
<Text html id='world' />
<Translation html id='world' />
</TestWrapper>,
);

Expand All @@ -19,7 +19,7 @@ describe('EOLocaleHtml', () => {
it('Should wrap in custom tag', () => {
const { container } = render(
<TestWrapper>
<Text html id='world' tagName='article' />
<Translation html id='world' tagName='article' />
</TestWrapper>,
);

Expand All @@ -29,7 +29,7 @@ describe('EOLocaleHtml', () => {
it('Should render strong tag', () => {
const { container } = render(
<TestWrapper>
<Text html id='world' />
<Translation html id='world' />
</TestWrapper>,
);

Expand All @@ -39,7 +39,7 @@ describe('EOLocaleHtml', () => {
it('Should render expected text in the strong tag', () => {
const { container } = render(
<TestWrapper language='ru'>
<Text html id='world' />
<Translation html id='world' />
</TestWrapper>,
);

Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/__tests__/on_error.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render } from '@testing-library/react';
import * as React from 'react';
import { Text } from '../components';
import { Translation } from '../components';
import { TestWrapper } from './test_wrapper';

describe('On error handler', () => {
Expand All @@ -9,7 +9,7 @@ describe('On error handler', () => {

render(
<TestWrapper onError={onError}>
<Text id='some_unique_id' />
<Translation id='some_unique_id' />
</TestWrapper>,
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { render } from '@testing-library/react';
import * as React from 'react';
import { Text } from '../components';
import { Translation } from '../components';
import { TestWrapper } from './test_wrapper';

describe('Text', () => {
it('Should render formatted message for en', () => {
const { getByTestId } = render(
<TestWrapper>
<Text id='hello' name='test' />
<Translation id='hello' name='test' />
</TestWrapper>,
);

Expand All @@ -17,7 +17,7 @@ describe('Text', () => {
it('Should render default message', () => {
const { getByTestId } = render(
<TestWrapper>
<Text id='none' defaultMessage='test' />
<Translation id='none' defaultMessage='test' />
</TestWrapper>,
);

Expand All @@ -27,7 +27,7 @@ describe('Text', () => {
it('Should render formatted message for ru', () => {
const { getByTestId } = render(
<TestWrapper language='ru'>
<Text id='hello' name='тест' />
<Translation id='hello' name='тест' />
</TestWrapper>,
);

Expand All @@ -39,7 +39,7 @@ describe('Text', () => {

const { getByTestId } = render(
<TestWrapper language='es' onError={onError}>
<Text id='hello' />
<Translation id='hello' />
</TestWrapper>,
);

Expand All @@ -50,7 +50,7 @@ describe('Text', () => {
it('Should render plural', () => {
const { getByTestId } = render(
<TestWrapper>
<Text id='test_plural' attempts={1} />
<Translation id='test_plural' attempts={1} />
</TestWrapper>,
);

Expand All @@ -62,7 +62,7 @@ describe('Text', () => {
it('Should render plural', () => {
const { getByTestId } = render(
<TestWrapper>
<Text id='test_plural' attempts={5} />
<Translation id='test_plural' attempts={5} />
</TestWrapper>,
);

Expand All @@ -72,7 +72,7 @@ describe('Text', () => {
it('Should render rus plural', () => {
const { getByTestId } = render(
<TestWrapper language='ru'>
<Text id='test_plural' confirmations={3} />
<Translation id='test_plural' confirmations={3} />
</TestWrapper>,
);

Expand All @@ -82,7 +82,7 @@ describe('Text', () => {
it('Should render rus plural', () => {
const { getByTestId } = render(
<TestWrapper language='ru'>
<Text id='test_plural' confirmations={1} />
<Translation id='test_plural' confirmations={1} />
</TestWrapper>,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props extends FormatMessageOptions {
tagName?: keyof React.ReactHTML;
}

export const Text: FC<PropsWithChildren<Props>> = ({
export const Translation: FC<PropsWithChildren<Props>> = ({
children,
defaultMessage,
html,
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './DateTime';
export * from './Numeric';
export * from './Text';
export * from './Translation';
export * from './TranslationsProvider';

0 comments on commit e1e5537

Please sign in to comment.