import * as React from 'react';
import { shallow } from 'enzyme';
import Password from '../Password';
-import { mockCurrentUser } from '../../../../helpers/testMocks';
+import { mockLoggedInUser } from '../../../../helpers/testMocks';
it('renders correctly', () => {
- expect(shallow(<Password user={mockCurrentUser()} />)).toMatchSnapshot();
+ expect(shallow(<Password user={mockLoggedInUser()} />)).toMatchSnapshot();
});
import { shallow } from 'enzyme';
import { App } from '../App';
import {
- mockCurrentUser,
+ mockLoggedInUser,
mockRouter,
mockIssue,
mockLocation
organization: 'John',
qualifier: 'Doe'
}}
- currentUser={mockCurrentUser()}
+ currentUser={mockLoggedInUser()}
fetchIssues={jest.fn().mockResolvedValue({
components: [referencedComponent],
effortTotal: 1,
import * as React from 'react';
import { shallow } from 'enzyme';
import MembersList from '../MembersList';
-import { mockOrganization, mockCurrentUser } from '../../../helpers/testMocks';
+import { mockLoggedInUser, mockOrganization } from '../../../helpers/testMocks';
const members = [
{ login: 'admin', name: 'Admin Istrator', avatar: '', groupCount: 3 },
function shallowRender(props: Partial<MembersList['props']> = {}) {
return shallow(
<MembersList
- currentUser={mockCurrentUser({ login: 'admin' })}
+ currentUser={mockLoggedInUser({ login: 'admin' })}
members={members}
organization={mockOrganization()}
organizationGroups={[]}
import { shallow } from 'enzyme';
import MembersListHeader, { Props } from '../MembersListHeader';
import {
+ mockLoggedInUser,
mockOrganization,
- mockCurrentUser,
mockOrganizationWithAlm
} from '../../../helpers/testMocks';
it('should not render link in help tooltip', () => {
expect(
shallowRender({
- currentUser: mockCurrentUser({ personalOrganization: 'foo' }),
+ currentUser: mockLoggedInUser({ personalOrganization: 'foo' }),
organization: mockOrganizationWithAlm({}, { membersSync: true })
}).find('HelpTooltip')
).toMatchSnapshot();
function shallowRender(props: Partial<Props> = {}) {
return shallow(
<MembersListHeader
- currentUser={mockCurrentUser()}
+ currentUser={mockLoggedInUser()}
handleSearch={jest.fn()}
organization={mockOrganization()}
total={8}
import { searchMembers, addMember, removeMember } from '../../../api/organizations';
import { searchUsersGroups, addUserToGroup, removeUserFromGroup } from '../../../api/user_groups';
import {
+ mockLoggedInUser,
mockOrganization,
- mockCurrentUser,
mockOrganizationWithAdminActions,
mockOrganizationWithAlm
} from '../../../helpers/testMocks';
function shallowRender(props: Partial<OrganizationMembers['props']> = {}) {
return shallow<OrganizationMembers>(
<OrganizationMembers
- currentUser={mockCurrentUser()}
+ currentUser={mockLoggedInUser()}
organization={mockOrganizationWithAdminActions()}
{...props}
/>
import { save } from '../../../../helpers/storage';
import {
mockAlmApplication,
- mockCurrentUser,
+ mockLoggedInUser,
mockOrganization
} from '../../../../helpers/testMocks';
function shallowRender(props: Partial<OrganizationBind['props']> = {}) {
return shallow<OrganizationBind>(
<OrganizationBind
- currentUser={mockCurrentUser()}
+ currentUser={mockLoggedInUser()}
organization={mockOrganization()}
{...props}
/>
import * as React from 'react';
import { shallow } from 'enzyme';
import { OrganizationEdit } from '../OrganizationEdit';
-import { mockCurrentUser } from '../../../../helpers/testMocks';
+import { mockLoggedInUser } from '../../../../helpers/testMocks';
it('smoke test', () => {
const organization = { key: 'foo', name: 'Foo' };
const wrapper = shallow(
<OrganizationEdit
- currentUser={mockCurrentUser()}
+ currentUser={mockLoggedInUser()}
organization={organization}
updateOrganization={jest.fn()}
/>
import * as React from 'react';
import { shallow } from 'enzyme';
import OrganizationNavigationHeader, { Props } from '../OrganizationNavigationHeader';
-import { mockOrganizationWithAlm, mockCurrentUser } from '../../../../helpers/testMocks';
+import {
+ mockOrganizationWithAlm,
+ mockCurrentUser,
+ mockLoggedInUser
+} from '../../../../helpers/testMocks';
it('renders', () => {
expect(shallowRender()).toMatchSnapshot();
it('renders for external user w/o alm integration', () => {
expect(
- shallowRender({ currentUser: mockCurrentUser({ externalProvider: 'github' }) })
+ shallowRender({ currentUser: mockLoggedInUser({ externalProvider: 'github' }) })
).toMatchSnapshot();
});
import { Meta } from '../MetaContainer';
import {
mockAppState,
- mockCurrentUser,
+ mockLoggedInUser,
mockOrganization,
mockComponent
} from '../../../../helpers/testMocks';
<Meta
appState={mockAppState({ organizationsEnabled: true })}
component={mockComponent()}
- currentUser={mockCurrentUser()}
+ currentUser={mockLoggedInUser()}
onComponentChange={jest.fn()}
organization={mockOrganization()}
userOrganizations={[mockOrganization()]}
import * as React from 'react';
import { shallow } from 'enzyme';
import { EmailForm } from '../EmailForm';
-import { mockCurrentUser } from '../../../../helpers/testMocks';
+import { mockLoggedInUser } from '../../../../helpers/testMocks';
it('should render correctly', () => {
- expect(shallow(<EmailForm currentUser={mockCurrentUser()} />)).toMatchSnapshot();
+ expect(shallow(<EmailForm currentUser={mockLoggedInUser()} />)).toMatchSnapshot();
});
import { shallow } from 'enzyme';
import { OnboardingModal, Props } from '../OnboardingModal';
import { click } from '../../../../helpers/testUtils';
-import { mockCurrentUser, mockOrganization } from '../../../../helpers/testMocks';
+import { mockLoggedInUser, mockOrganization } from '../../../../helpers/testMocks';
it('renders correctly', () => {
expect(shallowRender()).toMatchSnapshot();
it('should display organization list if any', () => {
const wrapper = shallowRender({
- currentUser: mockCurrentUser({ personalOrganization: 'personal' }),
+ currentUser: mockLoggedInUser({ personalOrganization: 'personal' }),
userOrganizations: [
mockOrganization({ key: 'a', name: 'Arthur' }),
mockOrganization({ key: 'd', name: 'Daniel Inc' }),
function shallowRender(props: Partial<Props> = {}) {
return shallow(
<OnboardingModal
- currentUser={mockCurrentUser()}
+ currentUser={mockLoggedInUser()}
onClose={jest.fn()}
onOpenProjectOnboarding={jest.fn()}
userOrganizations={[]}
getAlmMembersUrl,
getUserAlmKey
} from '../almIntegrations';
-import { mockCurrentUser } from '../testMocks';
+import { mockCurrentUser, mockLoggedInUser } from '../testMocks';
it('#getAlmMembersUrl', () => {
expect(getAlmMembersUrl('github', 'https://github.com/Foo')).toBe(
describe('getUserAlmKey', () => {
it('should return sanitized almKey', () => {
- expect(getUserAlmKey(mockCurrentUser({ externalProvider: 'bitbucketcloud' }))).toBe(
+ expect(getUserAlmKey(mockLoggedInUser({ externalProvider: 'bitbucketcloud' }))).toBe(
'bitbucket'
);
});
};
}
-export function mockCurrentUser(overrides: Partial<T.LoggedInUser> = {}): T.LoggedInUser {
+export function mockCurrentUser(overrides: Partial<T.CurrentUser> = {}): T.CurrentUser {
+ return {
+ isLoggedIn: false,
+ ...overrides
+ };
+}
+
+export function mockLoggedInUser(overrides: Partial<T.LoggedInUser> = {}): T.LoggedInUser {
return {
groups: [],
isLoggedIn: true,