Add jest tests for twenty-front (#2983)

* Add jest tests for twenty-front

Co-authored-by: v1b3m <vibenjamin6@gmail.com>

* Fix tests

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
gitstart-twenty
2023-12-15 17:53:20 +08:00
committed by GitHub
parent af9d3fb217
commit 5f7442cf23
27 changed files with 693 additions and 2 deletions

View File

@ -0,0 +1,121 @@
import { CurrentWorkspace } from '@/auth/states/currentWorkspaceState';
import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember';
import { getOnboardingStatus } from '../getOnboardingStatus';
describe('getOnboardingStatus', () => {
it('should return the correct status', () => {
const ongoingUserCreation = getOnboardingStatus({
isLoggedIn: false,
currentWorkspaceMember: null,
currentWorkspace: null,
});
const unknownStatus = getOnboardingStatus({
isLoggedIn: true,
currentWorkspaceMember: null,
currentWorkspace: null,
});
const ongoingWorkspaceCreation = getOnboardingStatus({
isLoggedIn: true,
currentWorkspaceMember: {
id: '1',
name: {
firstName: 'John',
lastName: 'Doe',
},
} as WorkspaceMember,
currentWorkspace: {
id: '1',
displayName: null,
} as CurrentWorkspace,
});
const ongoingProfileCreation = getOnboardingStatus({
isLoggedIn: true,
currentWorkspaceMember: {
id: '1',
name: {},
} as WorkspaceMember,
currentWorkspace: {
id: '1',
displayName: 'My Workspace',
} as CurrentWorkspace,
});
const completed = getOnboardingStatus({
isLoggedIn: true,
currentWorkspaceMember: {
id: '1',
name: {
firstName: 'John',
lastName: 'Doe',
},
} as WorkspaceMember,
currentWorkspace: {
id: '1',
displayName: 'My Workspace',
} as CurrentWorkspace,
});
const incomplete = getOnboardingStatus({
isLoggedIn: true,
currentWorkspaceMember: {
id: '1',
name: {
firstName: 'John',
lastName: 'Doe',
},
} as WorkspaceMember,
currentWorkspace: {
id: '1',
displayName: 'My Workspace',
subscriptionStatus: 'incomplete',
} as CurrentWorkspace,
isBillingEnabled: true,
});
const incompleteButBillingDisabled = getOnboardingStatus({
isLoggedIn: true,
currentWorkspaceMember: {
id: '1',
name: {
firstName: 'John',
lastName: 'Doe',
},
} as WorkspaceMember,
currentWorkspace: {
id: '1',
displayName: 'My Workspace',
subscriptionStatus: 'incomplete',
} as CurrentWorkspace,
});
const canceled = getOnboardingStatus({
isLoggedIn: true,
currentWorkspaceMember: {
id: '1',
name: {
firstName: 'John',
lastName: 'Doe',
},
} as WorkspaceMember,
currentWorkspace: {
id: '1',
displayName: 'My Workspace',
subscriptionStatus: 'canceled',
} as CurrentWorkspace,
isBillingEnabled: true,
});
expect(ongoingUserCreation).toBe('ongoing_user_creation');
expect(unknownStatus).toBe(undefined);
expect(ongoingWorkspaceCreation).toBe('ongoing_workspace_creation');
expect(ongoingProfileCreation).toBe('ongoing_profile_creation');
expect(completed).toBe('completed');
expect(incomplete).toBe('incomplete');
expect(canceled).toBe('canceled');
expect(incompleteButBillingDisabled).toBe('completed');
});
});