import * as React from 'react';
import { shallow } from 'enzyme';
import MetaTags from '../MetaTags';
+import { mockComponent } from '../../../../helpers/testUtils';
-const component = {
- key: 'my-project',
- tags: [],
+const component = mockComponent({
configuration: {
showSettings: false
- },
- organization: 'foo',
- qualifier: 'TRK',
- name: 'MyProject',
- breadcrumbs: []
-};
+ }
+});
-const componentWithTags = {
+const componentWithTags = mockComponent({
key: 'my-second-project',
tags: ['foo', 'bar'],
configuration: {
showSettings: true
},
- organization: 'foo',
- qualifier: 'TRK',
- name: 'MySecondProject',
- breadcrumbs: []
-};
+ name: 'MySecondProject'
+});
it('should render without tags and admin rights', () => {
expect(
*/
import { ShallowWrapper, ReactWrapper } from 'enzyme';
import { InjectedRouter } from 'react-router';
+import { EditionKey } from '../apps/marketplace/utils';
export const mockEvent = {
target: { blur() {} },
...overrides
} as InjectedRouter;
}
+
+export function mockAppState(overrides = {}): T.AppState {
+ return {
+ defaultOrganization: 'foo',
+ edition: EditionKey.community,
+ productionDatabase: true,
+ qualifiers: ['TRK'],
+ settings: {},
+ version: '1.0',
+ ...overrides
+ };
+}
+
+export function mockComponent(overrides = {}): T.Component {
+ return {
+ breadcrumbs: [],
+ key: 'my-project',
+ name: 'MyProject',
+ organization: 'foo',
+ qualifier: 'TRK',
+ qualityGate: { isDefault: true, key: '30', name: 'Sonar way' },
+ qualityProfiles: [mockQualityProfile()],
+ tags: [],
+ ...overrides
+ };
+}
+
+export function mockCurrentUser(overrides = {}): T.CurrentUser {
+ return {
+ isLoggedIn: true,
+ ...overrides
+ };
+}
+
+export function mockOrganization(overrides = {}): T.Organization {
+ return {
+ key: 'foo',
+ name: 'Foo',
+ ...overrides
+ };
+}
+
+export function mockQualityProfile(overrides = {}): T.ComponentQualityProfile {
+ return {
+ deleted: false,
+ key: 'my-qp',
+ language: 'ts',
+ name: 'Sonar way',
+ ...overrides
+ };
+}