locale.spec.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import {textWithMarkupMatcher} from 'sentry-test/utils';
  3. import {tct} from 'sentry/locale';
  4. describe('locale.gettextComponentTemplate', () => {
  5. it('should not wrap translated text in span', () => {
  6. // spaces are removed because pretter keeps trying to remove them in the snapshot
  7. expect(
  8. tct('hello[one]two[three:3]', {
  9. one: ' one',
  10. three: <code />,
  11. })
  12. ).toMatchInlineSnapshot(`
  13. <React.Fragment>
  14. <React.Fragment>
  15. <React.Fragment>
  16. hello
  17. </React.Fragment>
  18. <React.Fragment>
  19. one
  20. </React.Fragment>
  21. <React.Fragment>
  22. two
  23. </React.Fragment>
  24. <code>
  25. <React.Fragment>
  26. 3
  27. </React.Fragment>
  28. </code>
  29. </React.Fragment>
  30. </React.Fragment>
  31. `);
  32. });
  33. it('should render two component templates inside the same parent', () => {
  34. render(
  35. <div>
  36. {tct('1st: [one]', {
  37. one: 'one',
  38. })}
  39. {tct('2nd: [two]', {
  40. two: 'two',
  41. })}
  42. </div>
  43. );
  44. expect(
  45. screen.getByText(textWithMarkupMatcher('1st: one2nd: two'))
  46. ).toBeInTheDocument();
  47. });
  48. });