-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add prop labelAlignment to select component #1855
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,42 @@ describe('Select component', () => { | |
const component = mount(<Select label="Select Label" required />); | ||
expect(component.find('RequiredAsterisk').prop('required')).toBe(true); | ||
}); | ||
it('should set "left" to labelAlignment prop passed in the Label component', () => { | ||
const component = mount(<Select label="Select Label" required labelAlignment="left" />); | ||
expect(component.find('SelectStyledLabel').prop('labelAlignment')).toBe('left'); | ||
}); | ||
it('should set "right" to labelAlignment prop passed in the Label component', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar blocks of code found in 2 locations. Consider refactoring. |
||
const component = mount(<Select label="Select Label" required labelAlignment="right" />); | ||
expect(component.find('SelectStyledLabel').prop('labelAlignment')).toBe('right'); | ||
}); | ||
it('should set "center" to labelAlignment if prop not passed (default) in the Label component', () => { | ||
const component = mount(<Select label="Select Label" required />); | ||
expect(component.find('SelectStyledLabel').prop('labelAlignment')).toBe('center'); | ||
}); | ||
it('renders correctly with label left aligned', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar blocks of code found in 3 locations. Consider refactoring. |
||
const component = mount(<Select label="Select Label" required labelAlignment="left" />); | ||
const elem = component.find('SelectStyledLabel'); | ||
|
||
expect(getComputedStyle(elem.getDOMNode()).getPropertyValue('align-self')).toBe( | ||
'flex-start', | ||
); | ||
}); | ||
it('renders correctly with label right aligned', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar blocks of code found in 3 locations. Consider refactoring. |
||
const component = mount(<Select label="Select Label" required labelAlignment="right" />); | ||
const elem = component.find('SelectStyledLabel'); | ||
|
||
expect(getComputedStyle(elem.getDOMNode()).getPropertyValue('align-self')).toBe('flex-end'); | ||
}); | ||
it('renders correctly with label centered (default)', () => { | ||
const component = mount(<Select label="Select Label" required />); | ||
const elem = component.find('SelectStyledLabel'); | ||
|
||
expect(getComputedStyle(elem.getDOMNode()).getPropertyValue('align-self')).toBe('center'); | ||
}); | ||
it('renders correctly with label centered by passing prop (explicit)', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar blocks of code found in 3 locations. Consider refactoring. |
||
const component = mount(<Select label="Select Label" required labelAlignment="center" />); | ||
const elem = component.find('SelectStyledLabel'); | ||
|
||
expect(getComputedStyle(elem.getDOMNode()).getPropertyValue('align-self')).toBe('center'); | ||
luisFilipePT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.