Commit 783124ad authored by Jannik Lehmann's avatar Jannik Lehmann

Refactor Spec

parent 17c667e8
...@@ -3,7 +3,20 @@ import { GlTab, GlTabs, GlSprintf, GlLink } from '@gitlab/ui'; ...@@ -3,7 +3,20 @@ import { GlTab, GlTabs, GlSprintf, GlLink } from '@gitlab/ui';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import FeatureCard from './feature_card.vue'; import FeatureCard from './feature_card.vue';
export const i18n = {
compliance: s__('SecurityConfiguration|Compliance'),
securityTesting: s__('SecurityConfiguration|Security testing'),
securityTestingDescription: s__(
`SecurityConfiguration|The status of the tools only applies to the
default branch and is based on the %{linkStart}latest pipeline%{linkEnd}.
Once you've enabled a scan for the default branch, any subsequent feature
branch you create will include the scan.`,
),
securityConfiguration: __('Security Configuration'),
};
export default { export default {
i18n,
components: { components: {
GlTab, GlTab,
GlLink, GlLink,
...@@ -22,17 +35,6 @@ export default { ...@@ -22,17 +35,6 @@ export default {
default: '', default: '',
}, },
}, },
i18n: {
compliance: s__('SecurityConfiguration|Compliance'),
securityTesting: s__('SecurityConfiguration|Security testing'),
securityTestingDescription: s__(
`SecurityConfiguration|The status of the tools only applies to the
default branch and is based on the %{linkStart}latest pipeline%{linkEnd}.
Once you've enabled a scan for the default branch, any subsequent feature
branch you create will include the scan.`,
),
securityConfiguration: __('Security Configuration'),
},
}; };
</script> </script>
......
...@@ -9,7 +9,10 @@ import { ...@@ -9,7 +9,10 @@ import {
SAST_CONFIG_HELP_PATH, SAST_CONFIG_HELP_PATH,
} from '~/security_configuration/components/constants'; } from '~/security_configuration/components/constants';
import FeatureCard from '~/security_configuration/components/feature_card.vue'; import FeatureCard from '~/security_configuration/components/feature_card.vue';
import RedesignedSecurityConfigurationApp from '~/security_configuration/components/redesigned_app.vue'; import RedesignedSecurityConfigurationApp, {
i18n,
} from '~/security_configuration/components/redesigned_app.vue';
import { REPORT_TYPE_SAST } from '~/vue_shared/security_reports/constants';
describe('NewApp component', () => { describe('NewApp component', () => {
let wrapper; let wrapper;
...@@ -73,7 +76,7 @@ describe('NewApp component', () => { ...@@ -73,7 +76,7 @@ describe('NewApp component', () => {
it('renders sub-heading with correct text', () => { it('renders sub-heading with correct text', () => {
const subHeading = findSubHeading(); const subHeading = findSubHeading();
expect(subHeading).toExist(); expect(subHeading).toExist();
expect(subHeading.text()).toContain(RedesignedSecurityConfigurationApp.i18n.securityTesting); expect(subHeading.text()).toContain(i18n.securityTesting);
}); });
it('renders right amount of feature cards for given props with correct props', () => { it('renders right amount of feature cards for given props with correct props', () => {
...@@ -98,7 +101,7 @@ describe('NewApp component', () => { ...@@ -98,7 +101,7 @@ describe('NewApp component', () => {
it('should show latest pipeline info with correct link when latestPipelinePath is defined', () => { it('should show latest pipeline info with correct link when latestPipelinePath is defined', () => {
expect(findByTestId('latest-pipeline-info').exists()).toBe(true); expect(findByTestId('latest-pipeline-info').exists()).toBe(true);
expect(findByTestId('latest-pipeline-info').text()).toMatchInterpolatedText( expect(findByTestId('latest-pipeline-info').text()).toMatchInterpolatedText(
RedesignedSecurityConfigurationApp.i18n.securityTestingDescription, i18n.securityTestingDescription,
); );
expect(findByTestId('latest-pipeline-info').find('a').attributes('href')).toBe('test/path'); expect(findByTestId('latest-pipeline-info').find('a').attributes('href')).toBe('test/path');
}); });
......
...@@ -54,26 +54,26 @@ const expectedOutputCustomFeature = { ...@@ -54,26 +54,26 @@ const expectedOutputCustomFeature = {
augmentedComplianceFeatures: mockComplianceFeatures, augmentedComplianceFeatures: mockComplianceFeatures,
}; };
describe('augmentFeatures', () => { describe('returns an object with augmentedSecurityFeatures and augmentedComplianceFeatures when', () => {
it('augments features array correctly when given an empty array', () => { it('given an empty array', () => {
expect(augmentFeatures(mockSecurityFeatures, mockComplianceFeatures, [])).toEqual( expect(augmentFeatures(mockSecurityFeatures, mockComplianceFeatures, [])).toEqual(
expectedOutputDefault, expectedOutputDefault,
); );
}); });
it('augments features array correctly when given an invalid populated array', () => { it('given an invalid populated array', () => {
expect( expect(
augmentFeatures(mockSecurityFeatures, mockComplianceFeatures, mockInvalidCustomFeature), augmentFeatures(mockSecurityFeatures, mockComplianceFeatures, mockInvalidCustomFeature),
).toEqual(expectedOutputDefault); ).toEqual(expectedOutputDefault);
}); });
it('augments features array correctly when features have secondary key', () => { it('features have secondary key', () => {
expect(augmentFeatures(mockSecurityFeatures, mockFeaturesWithSecondary, [])).toEqual( expect(augmentFeatures(mockSecurityFeatures, mockFeaturesWithSecondary, [])).toEqual(
expectedOutputSecondary, expectedOutputSecondary,
); );
}); });
it('augments features array correctly when given a valid populated array', () => { it('given a valid populated array', () => {
expect( expect(
augmentFeatures(mockSecurityFeatures, mockComplianceFeatures, mockValidCustomFeature), augmentFeatures(mockSecurityFeatures, mockComplianceFeatures, mockValidCustomFeature),
).toEqual(expectedOutputCustomFeature); ).toEqual(expectedOutputCustomFeature);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment