diff options
Diffstat (limited to 'server/sonar-web/src/main/js')
16 files changed, 129 insertions, 241 deletions
diff --git a/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/AboutApp-test.tsx.snap b/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/AboutApp-test.tsx.snap index 0a365f46bfb..5a92273dc63 100644 --- a/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/AboutApp-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/AboutApp-test.tsx.snap @@ -188,7 +188,7 @@ exports[`should render correctly 1`] = ` <span className="little-spacer-right" > - <BugIcon /> + <MOCKBugIcon /> </span> issue.type.BUG.plural </td> @@ -225,7 +225,7 @@ exports[`should render correctly 1`] = ` <span className="little-spacer-right" > - <VulnerabilityIcon /> + <MOCKVulnerabilityIcon /> </span> issue.type.VULNERABILITY.plural </td> @@ -262,7 +262,7 @@ exports[`should render correctly 1`] = ` <span className="little-spacer-right" > - <CodeSmellIcon /> + <MOCKCodeSmellIcon /> </span> issue.type.CODE_SMELL.plural </td> @@ -299,7 +299,7 @@ exports[`should render correctly 1`] = ` <span className="little-spacer-right" > - <SecurityHotspotIcon /> + <MOCKSecurityHotspotIcon /> </span> issue.type.SECURITY_HOTSPOT.plural </td> @@ -522,7 +522,7 @@ exports[`should render correctly 1`] = ` <div className="pull-left little-spacer-right" > - <BugIcon /> + <MOCKBugIcon /> </div> <p className="about-page-text overflow-hidden" @@ -543,7 +543,7 @@ exports[`should render correctly 1`] = ` <div className="pull-left little-spacer-right" > - <VulnerabilityIcon /> + <MOCKVulnerabilityIcon /> </div> <p className="about-page-text overflow-hidden" @@ -558,7 +558,7 @@ exports[`should render correctly 1`] = ` <div className="pull-left little-spacer-right" > - <SecurityHotspotIcon /> + <MOCKSecurityHotspotIcon /> </div> <p className="about-page-text overflow-hidden" @@ -579,7 +579,7 @@ exports[`should render correctly 1`] = ` <div className="pull-left little-spacer-right" > - <CodeSmellIcon /> + <MOCKCodeSmellIcon /> </div> <p className="about-page-text overflow-hidden" @@ -778,7 +778,7 @@ exports[`should render correctly 1`] = ` onClick={[Function]} style={Object {}} > - <TagsIcon /> + <MOCKTagsIcon /> <span className="little-spacer-left" > @@ -806,7 +806,7 @@ exports[`should render correctly 1`] = ` onClick={[Function]} style={Object {}} > - <TagsIcon /> + <MOCKTagsIcon /> <span className="little-spacer-left" > @@ -834,7 +834,7 @@ exports[`should render correctly 1`] = ` onClick={[Function]} style={Object {}} > - <TagsIcon /> + <MOCKTagsIcon /> <span className="little-spacer-left" > @@ -862,7 +862,7 @@ exports[`should render correctly 1`] = ` onClick={[Function]} style={Object {}} > - <TagsIcon /> + <MOCKTagsIcon /> <span className="little-spacer-left" > @@ -890,7 +890,7 @@ exports[`should render correctly 1`] = ` onClick={[Function]} style={Object {}} > - <TagsIcon /> + <MOCKTagsIcon /> <span className="little-spacer-left" > diff --git a/server/sonar-web/src/main/js/apps/groups/components/__tests__/__snapshots__/EditMembers-test.tsx.snap b/server/sonar-web/src/main/js/apps/groups/components/__tests__/__snapshots__/EditMembers-test.tsx.snap index daf6e70e72b..98241e10f0c 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/__tests__/__snapshots__/EditMembers-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/groups/components/__tests__/__snapshots__/EditMembers-test.tsx.snap @@ -36,7 +36,7 @@ exports[`should edit members 1`] = ` } type="button" > - <BulletListIcon /> + <MOCKBulletListIcon /> </button> </Button> </ButtonIcon> @@ -79,7 +79,7 @@ exports[`should edit members 2`] = ` } type="button" > - <BulletListIcon /> + <MOCKBulletListIcon /> </button> </Button> </ButtonIcon> @@ -441,7 +441,7 @@ exports[`should edit members 2`] = ` loading={false} timeout={100} > - <SearchIcon + <MOCKSearchIcon className="search-box-magnifier" /> </DeferredSpinner> @@ -553,7 +553,7 @@ exports[`should edit members 3`] = ` } type="button" > - <BulletListIcon /> + <MOCKBulletListIcon /> </button> </Button> </ButtonIcon> diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx index 9631e25842a..3389df8bb61 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx @@ -25,7 +25,7 @@ import AlertSuccessIcon from '../../../../components/icons-components/AlertSucce import { HealthType, SysValue, SysValueObject } from '../../../../api/system'; import { HEALTH_FIELD } from '../../utils'; -interface Props { +export interface Props { name: string; value: SysValue; } @@ -39,9 +39,9 @@ export default function SysInfoItem({ name, value }: Props): JSX.Element { } switch (typeof value) { case 'boolean': - return <BooleanItem value={value as boolean} />; + return <BooleanItem value={value} />; case 'object': - return <ObjectItem value={value as SysValueObject} />; + return <ObjectItem value={value} />; default: return <code>{value}</code>; } diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx index d2def0a2fb2..7d4db450fbe 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx @@ -18,45 +18,61 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { shallow, mount } from 'enzyme'; -import SysInfoItem from '../SysInfoItem'; - -jest.mock('../../../../../components/icons-components/AlertSuccessIcon'); +import { shallow } from 'enzyme'; +import SysInfoItem, { Props } from '../SysInfoItem'; it('should render string', () => { - const wrapper = shallow(<SysInfoItem name="foo" value="/some/path/as/an/example" />); - expect(wrapper.find('code').text()).toBe('/some/path/as/an/example'); + expect( + shallowRender('/some/path/as/an/example') + .find('code') + .text() + ).toBe('/some/path/as/an/example'); }); it('should render object', () => { - const wrapper = shallow(<SysInfoItem name="foo" value={{ bar: 'baz' }} />); - expect(wrapper.find('ObjectItem').prop('value')).toEqual({ bar: 'baz' }); + expect( + shallowRender({ bar: 'baz' }) + .find('ObjectItem') + .prop('value') + ).toEqual({ bar: 'baz' }); }); it('should render boolean', () => { - const wrapper = shallow(<SysInfoItem name="foo" value={true} />); - expect(wrapper.find('BooleanItem').prop('value')).toBe(true); + expect( + shallowRender(true) + .find('BooleanItem') + .prop('value') + ).toBe(true); }); it('should render health item', () => { - const wrapper = shallow(<SysInfoItem name="Health" value="GREEN" />); - expect(wrapper.find('HealthItem').prop('health')).toBe('GREEN'); -}); - -it('should render object correctly', () => { expect( - mount( - <SysInfoItem name="test" value={{ foo: 'Far', bar: { a: 1, b: 'b' }, baz: true }} /> - ).find('ObjectItem') - ).toMatchSnapshot(); + shallowRender('GREEN', 'Health') + .find('HealthItem') + .prop('health') + ).toBe('GREEN'); }); it('should render `true`', () => { - const wrapper = mount(<SysInfoItem name="test" value={true} />); - expect(wrapper.find('AlertSuccessIcon').exists()).toBeTruthy(); + const wrapper = shallowRender(true); + expect(wrapper.find('BooleanItem').exists()).toBe(true); + expect(wrapper.dive()).toMatchSnapshot(); }); it('should render `false`', () => { - const wrapper = mount(<SysInfoItem name="test" value={false} />); - expect(wrapper.find('AlertErrorIcon').exists()).toBeTruthy(); + const wrapper = shallowRender(false); + expect(wrapper.find('BooleanItem').exists()).toBe(true); + expect(wrapper.dive()).toMatchSnapshot(); }); + +it('should render object correctly', () => { + expect( + shallowRender({ foo: 'Far', bar: { a: 1, b: 'b' }, baz: true }) + .find('ObjectItem') + .dive() + ).toMatchSnapshot(); +}); + +function shallowRender(value: Props['value'], name: Props['name'] = 'foo') { + return shallow(<SysInfoItem name={name} value={value} />); +} diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap index 7c39d65bb9e..212e5d97aa1 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap @@ -1,192 +1,64 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`should render \`false\` 1`] = `<AlertErrorIcon />`; + +exports[`should render \`true\` 1`] = `<AlertSuccessIcon />`; + exports[`should render object correctly 1`] = ` -Array [ - <ObjectItem - value={ - Object { - "bar": Object { - "a": 1, - "b": "b", - }, - "baz": true, - "foo": "Far", - } - } - > - <table - className="data" +<table + className="data" +> + <tbody> + <tr + key="foo" + > + <td + className="thin nowrap" + > + foo + </td> + <td> + <SysInfoItem + name="foo" + value="Far" + /> + </td> + </tr> + <tr + key="bar" > - <tbody> - <tr - key="foo" - > - <td - className="thin nowrap" - > - foo - </td> - <td> - <SysInfoItem - name="foo" - value="Far" - > - <code> - Far - </code> - </SysInfoItem> - </td> - </tr> - <tr - key="bar" - > - <td - className="thin nowrap" - > - bar - </td> - <td> - <SysInfoItem - name="bar" - value={ - Object { - "a": 1, - "b": "b", - } - } - > - <ObjectItem - value={ - Object { - "a": 1, - "b": "b", - } - } - > - <table - className="data" - > - <tbody> - <tr - key="a" - > - <td - className="thin nowrap" - > - a - </td> - <td> - <SysInfoItem - name="a" - value={1} - > - <code> - 1 - </code> - </SysInfoItem> - </td> - </tr> - <tr - key="b" - > - <td - className="thin nowrap" - > - b - </td> - <td> - <SysInfoItem - name="b" - value="b" - > - <code> - b - </code> - </SysInfoItem> - </td> - </tr> - </tbody> - </table> - </ObjectItem> - </SysInfoItem> - </td> - </tr> - <tr - key="baz" - > - <td - className="thin nowrap" - > - baz - </td> - <td> - <SysInfoItem - name="baz" - value={true} - > - <BooleanItem - value={true} - > - <AlertSuccessIcon /> - </BooleanItem> - </SysInfoItem> - </td> - </tr> - </tbody> - </table> - </ObjectItem>, - <ObjectItem - value={ - Object { - "a": 1, - "b": "b", - } - } - > - <table - className="data" + <td + className="thin nowrap" + > + bar + </td> + <td> + <SysInfoItem + name="bar" + value={ + Object { + "a": 1, + "b": "b", + } + } + /> + </td> + </tr> + <tr + key="baz" > - <tbody> - <tr - key="a" - > - <td - className="thin nowrap" - > - a - </td> - <td> - <SysInfoItem - name="a" - value={1} - > - <code> - 1 - </code> - </SysInfoItem> - </td> - </tr> - <tr - key="b" - > - <td - className="thin nowrap" - > - b - </td> - <td> - <SysInfoItem - name="b" - value="b" - > - <code> - b - </code> - </SysInfoItem> - </td> - </tr> - </tbody> - </table> - </ObjectItem>, -] + <td + className="thin nowrap" + > + baz + </td> + <td> + <SysInfoItem + name="baz" + value={true} + /> + </td> + </tr> + </tbody> +</table> `; diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/__snapshots__/NewProjectForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/__snapshots__/NewProjectForm-test.tsx.snap index 94a01466fdb..07ce9faa675 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/__snapshots__/NewProjectForm-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/__snapshots__/NewProjectForm-test.tsx.snap @@ -157,7 +157,7 @@ exports[`creates new project 3`] = ` } type="button" > - <DeleteIcon /> + <MOCKDeleteIcon /> </button> </Button> </ButtonIcon> @@ -215,7 +215,7 @@ exports[`deletes project 1`] = ` } type="button" > - <DeleteIcon /> + <MOCKDeleteIcon /> </button> </Button> </ButtonIcon> diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/AlertSuccessIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/AlertSuccessIcon.tsx index 6f3c229e6e1..c597a641ba6 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/AlertSuccessIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/AlertSuccessIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function AlertSuccessIcon() { +export default function MOCKAlertSuccessIcon() { return null; } diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/BugIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/BugIcon.tsx index 6500ff94ef3..987265294fc 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/BugIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/BugIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function BugIcon() { +export default function MOCKBugIcon() { return null; } diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/BulletListIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/BulletListIcon.tsx index 76afa5e10e3..1ba3b49c79c 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/BulletListIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/BulletListIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function BulletListIcon() { +export default function MOCKBulletListIcon() { return null; } diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/ClearIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/ClearIcon.tsx index be30a6ea7be..9565391375c 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/ClearIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/ClearIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function ClearIcon() { +export default function MOCKClearIcon() { return null; } diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/CodeSmellIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/CodeSmellIcon.tsx index 2ac884d8b5f..8fb340f47c9 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/CodeSmellIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/CodeSmellIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function CodeSmellIcon() { +export default function MOCKCodeSmellIcon() { return null; } diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/DeleteIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/DeleteIcon.tsx index 07f11e31f4f..8b347e92d5b 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/DeleteIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/DeleteIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function DeleteIcon() { +export default function MOCKDeleteIcon() { return null; } diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/SearchIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/SearchIcon.tsx index fc75c18a3f1..323ea37cd8d 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/SearchIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/SearchIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function SearchIcon() { +export default function MOCKSearchIcon() { return null; } diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/SecurityHotspotIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/SecurityHotspotIcon.tsx index bbac07e0e74..8b817c65826 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/SecurityHotspotIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/SecurityHotspotIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function SecurityHotspotIcon() { +export default function MOCKSecurityHotspotIcon() { return null; } diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/TagsIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/TagsIcon.tsx index df33ee271b8..17223251155 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/TagsIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/TagsIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function TagsIcon() { +export default function MOCKTagsIcon() { return null; } diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/VulnerabilityIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/VulnerabilityIcon.tsx index fc4bc119626..77038c6540f 100644 --- a/server/sonar-web/src/main/js/components/icons-components/__mocks__/VulnerabilityIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/VulnerabilityIcon.tsx @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function VulnerabilityIcon() { +export default function MOCKVulnerabilityIcon() { return null; } |