Skip to content

Commit 41da913

Browse files
committed
Added some test - Can remove if not needed
1 parent b46b127 commit 41da913

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/incubator/TextField/__tests__/index.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,33 @@ describe('TextField', () => {
8383
const validationMessageElement = renderTree.queryByText(props.validationMessage);
8484
expect(validationMessageElement).toBe(null);
8585
});
86+
87+
describe('Mandatory Indication', () => {
88+
it('Should show mandatory star indication - 1', async () => {
89+
const renderTree = render(<TestCase testID={'field'} validate={'required'} label={'Label'} showMandatoryIndication/>);
90+
const label = renderTree.getByTestId('field.label');
91+
const text = label.children[0];
92+
expect(text).toEqual('Label*');
93+
});
94+
it('Should show mandatory star indication - 2', () => {
95+
const renderTree = render(<TestCase testID={'field'} validate={['email', 'required']} label={'Label'} showMandatoryIndication/>);
96+
const label = renderTree.getByTestId('field.label');
97+
const text = label.children[0];
98+
expect(text).toEqual('Label*');
99+
});
100+
it('Should not show mandatory star indication - 3', () => {
101+
const renderTree = render(<TestCase testID={'field'} validate={['email', 'required']} label={'Label'}/>);
102+
const label = renderTree.getByTestId('field.label');
103+
const text = label.children[0];
104+
expect(text).not.toEqual('Label*');
105+
});
106+
it('Should not show mandatory star indication - 3', () => {
107+
const renderTree = render(<TestCase testID={'field'} validate={['email']} label={'Label'} showMandatoryIndication/>);
108+
const label = renderTree.getByTestId('field.label');
109+
const text = label.children[0];
110+
expect(text).not.toEqual('Label*');
111+
});
112+
});
86113
});
87114

88115
describe('defaultValue', () => {

0 commit comments

Comments
 (0)