From 265d7cb00b7c898b24f28f5d063c400c6bd8e454 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Tue, 25 Jun 2019 15:41:17 +0200 Subject: [PATCH] fixup! SONAR-12232 Add security review to portfolio projects list --- .../__tests__/ComponentMeasure-test.tsx | 55 ++++++++++++------- .../ComponentMeasure-test.tsx.snap | 20 ++++++- 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentMeasure-test.tsx b/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentMeasure-test.tsx index 2b38649aa39..23a3a5019b1 100644 --- a/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentMeasure-test.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentMeasure-test.tsx @@ -20,37 +20,52 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ComponentMeasure from '../ComponentMeasure'; - -const METRIC = { id: '1', key: 'coverage', type: 'PERCENT', name: 'Coverage' }; -const LEAK_METRIC = { id: '2', key: 'new_coverage', type: 'PERCENT', name: 'Coverage on New Code' }; -const COMPONENT = { key: 'foo', name: 'Foo', qualifier: 'TRK' }; -const COMPONENT_MEASURE = { - ...COMPONENT, - measures: [{ value: '3.0', periods: [{ index: 1, value: '10.0' }], metric: METRIC.key }] -}; +import { mockMetric, mockMeasure, mockComponentMeasure } from '../../../../helpers/testMocks'; it('renders correctly', () => { - expect( - shallow() - ).toMatchSnapshot(); + expect(shallowRender()).toMatchSnapshot(); }); it('renders correctly for leak values', () => { expect( shallow( ) ).toMatchSnapshot(); }); -it('renders correctly when no measure found', () => { - expect(shallow()).toMatchSnapshot(); +it('renders correctly when component has no measures', () => { + expect( + shallowRender({ component: mockComponentMeasure(false, { measures: undefined }) }) + ).toMatchSnapshot(); +}); + +it('should render correctly when no measure matches the metric', () => { + expect(shallowRender({ metric: mockMetric({ key: 'nonexistent_key' }) })).toMatchSnapshot(); +}); + +it('should render correctly for releasability rating', () => { + expect( + shallowRender({ + component: mockComponentMeasure(false, { + measures: [mockMeasure({ metric: 'alert_status' })] + }), + metric: mockMetric({ key: 'releasability_rating' }) + }) + ).toMatchSnapshot(); }); + +function shallowRender(overrides: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentMeasure-test.tsx.snap b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentMeasure-test.tsx.snap index 824a3eb07a0..18298c07a08 100644 --- a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentMeasure-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentMeasure-test.tsx.snap @@ -4,7 +4,7 @@ exports[`renders correctly 1`] = ` `; @@ -12,8 +12,22 @@ exports[`renders correctly for leak values 1`] = ` `; -exports[`renders correctly when no measure found 1`] = ``; +exports[`renders correctly when component has no measures 1`] = ``; + +exports[`should render correctly for releasability rating 1`] = ` + +`; + +exports[`should render correctly when no measure matches the metric 1`] = ` + + — + +`; -- 2.39.5