|
1 | 1 | import { render } from '@testing-library/react';
|
2 | 2 | import * as React from 'react';
|
3 |
| -import { Colors } from '../../essentials'; |
| 3 | +import { SemanticColors } from '../../essentials/Colors/Colors'; |
| 4 | + |
4 | 5 | import { Text } from './Text';
|
5 | 6 |
|
6 | 7 | describe('Text', () => {
|
7 |
| - it('renders a <span> by default', () => { |
8 |
| - expect(render(<Text />)).toMatchHtmlTag('span'); |
| 8 | + describe('default render', () => { |
| 9 | + it('renders a <span> by default', () => { |
| 10 | + expect(render(<Text />)).toMatchHtmlTag('span'); |
| 11 | + }); |
| 12 | + |
| 13 | + it('has a primary color by default', () => { |
| 14 | + expect(render(<Text />).container.firstChild).toHaveStyle(` |
| 15 | + color: ${SemanticColors.text.primary}; |
| 16 | + `); |
| 17 | + }); |
| 18 | + |
| 19 | + it('renders the children', () => { |
| 20 | + expect(render(<Text>Content</Text>).getByText('Content')).toBeInTheDocument(); |
| 21 | + }); |
9 | 22 | });
|
10 | 23 |
|
11 | 24 | it('respects the "as" prop', () => {
|
12 | 25 | expect(render(<Text as="b" />)).toMatchHtmlTag('b');
|
13 | 26 | });
|
14 | 27 |
|
15 |
| - it('renders the children', () => { |
16 |
| - expect(render(<Text>Content</Text>).getByText('Content')).toBeInTheDocument(); |
| 28 | + it('has an inverted primary color if inverted property is set', () => { |
| 29 | + expect(render(<Text inverted />).container.firstChild).toHaveStyle(` |
| 30 | + color: ${SemanticColors.text.primaryInverted}; |
| 31 | + `); |
17 | 32 | });
|
18 | 33 |
|
19 | 34 | describe('if the weak property is set', () => {
|
20 | 35 | it('has a dim color', () => {
|
21 | 36 | expect(render(<Text weak />).container.firstChild).toHaveStyle(`
|
22 |
| - color: ${Colors.AUTHENTIC_BLUE_550}; |
| 37 | + color: ${SemanticColors.text.secondary}; |
23 | 38 | `);
|
24 | 39 | });
|
25 | 40 |
|
26 | 41 | it('has a dimmer color if inverted', () => {
|
27 | 42 | expect(render(<Text weak inverted />).container.firstChild).toHaveStyle(`
|
28 |
| - color: ${Colors.AUTHENTIC_BLUE_350}; |
| 43 | + color: ${SemanticColors.text.secondaryInverted}; |
| 44 | + `); |
| 45 | + }); |
| 46 | + }); |
| 47 | + |
| 48 | + describe('if the `secondary` property is set', () => { |
| 49 | + it('has a dim color', () => { |
| 50 | + expect(render(<Text secondary />).container.firstChild).toHaveStyle(` |
| 51 | + color: ${SemanticColors.text.secondary}; |
| 52 | + `); |
| 53 | + }); |
| 54 | + |
| 55 | + it('has a dimmer color if inverted', () => { |
| 56 | + expect(render(<Text secondary inverted />).container.firstChild).toHaveStyle(` |
| 57 | + color: ${SemanticColors.text.secondaryInverted}; |
29 | 58 | `);
|
30 | 59 | });
|
31 | 60 | });
|
32 | 61 |
|
33 | 62 | describe('if the disabled property is set', () => {
|
34 | 63 | it('has the disabled color', () => {
|
35 | 64 | expect(render(<Text disabled />).container.firstChild).toHaveStyle(`
|
36 |
| - color: ${Colors.AUTHENTIC_BLUE_350}; |
| 65 | + color: ${SemanticColors.text.disabled}; |
37 | 66 | `);
|
38 | 67 | });
|
39 | 68 | it('has a stronger disabled color if inverted', () => {
|
40 | 69 | expect(render(<Text disabled inverted />).container.firstChild).toHaveStyle(`
|
41 |
| - color: ${Colors.AUTHENTIC_BLUE_550}; |
| 70 | + color: ${SemanticColors.text.disabledInverted}; |
42 | 71 | `);
|
43 | 72 | });
|
44 | 73 | });
|
45 |
| - |
46 |
| - it('has a bright color if inverted property is set', () => { |
47 |
| - expect(render(<Text inverted />).container.firstChild).toHaveStyle(` |
48 |
| - color: ${Colors.WHITE}; |
49 |
| - `); |
50 |
| - }); |
51 | 74 | });
|
0 commit comments