@@ -83,6 +83,33 @@ describe('TextField', () => {
83
83
const validationMessageElement = renderTree . queryByText ( props . validationMessage ) ;
84
84
expect ( validationMessageElement ) . toBe ( null ) ;
85
85
} ) ;
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
+ } ) ;
86
113
} ) ;
87
114
88
115
describe ( 'defaultValue' , ( ) => {
0 commit comments