generated from graasp/graasp-repo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16cdb81
commit 6d21f87
Showing
13 changed files
with
86 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ItemLoginSchema, ItemLoginSchemaType } from './itemLogin.js'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
export function itemLoginSchemaFactory( | ||
itemLoginSchema: Partial<ItemLoginSchema> & Pick<ItemLoginSchema, 'item'>, | ||
): ItemLoginSchema { | ||
return { | ||
id: faker.string.uuid(), | ||
type: ItemLoginSchemaType.Username, | ||
createdAt: faker.date.anytime().toISOString(), | ||
updatedAt: faker.date.anytime().toISOString(), | ||
...itemLoginSchema, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,40 @@ | ||
import { CompleteMember, MemberType } from './member.js'; | ||
import { | ||
BaseAccount, | ||
CompleteGuest, | ||
CompleteMember, | ||
MemberType, | ||
} from './member.js'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
function baseAccountFactory<T extends MemberType>( | ||
baseAccount: Partial<BaseAccount> & { type: T }, | ||
): BaseAccount & { type: T } { | ||
return { | ||
id: faker.string.uuid(), | ||
name: faker.person.fullName(), | ||
createdAt: faker.date.anytime().toISOString(), | ||
updatedAt: faker.date.anytime().toISOString(), | ||
...baseAccount, | ||
}; | ||
} | ||
|
||
export const MemberFactory = ( | ||
m: Partial<CompleteMember> = {}, | ||
): CompleteMember => ({ | ||
id: faker.string.uuid(), | ||
name: faker.person.fullName(), | ||
email: faker.internet.email(), | ||
createdAt: faker.date.anytime().toISOString(), | ||
updatedAt: faker.date.anytime().toISOString(), | ||
extra: faker.helpers.arrayElement([ | ||
{ lang: faker.helpers.arrayElement(['en', 'fr', 'de']) }, | ||
{}, | ||
]), | ||
// todo: handle other member type when useful in backend | ||
type: MemberType.Individual, | ||
enableSaveActions: m.enableSaveActions ?? true, | ||
isValidated: m.isValidated ?? true, | ||
...baseAccountFactory({ type: MemberType.Individual }), | ||
...m, | ||
}); | ||
|
||
export const GuestFactory = ( | ||
g: Partial<CompleteGuest> & Pick<CompleteGuest, 'itemLoginSchema'>, | ||
): CompleteGuest => ({ | ||
...baseAccountFactory({ type: MemberType.Guest }), | ||
...g, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
||
import { isPseudoMember } from './member.js'; | ||
import { MemberType, isPseudoMember } from './member.js'; | ||
|
||
describe('Member Util Tests', () => { | ||
beforeEach(() => { | ||
|
@@ -9,16 +9,14 @@ describe('Member Util Tests', () => { | |
|
||
describe('isPseudoMember', () => { | ||
it('check successfully member is pseudonymized for false values', () => { | ||
const res1 = isPseudoMember({ email: 'mail' }); | ||
const res1 = isPseudoMember({ type: MemberType.Individual }); | ||
expect(res1).toBeFalsy(); | ||
const res2 = isPseudoMember({ email: '[email protected]' }); | ||
const res2 = isPseudoMember({ type: MemberType.Group }); | ||
expect(res2).toBeFalsy(); | ||
const res3 = isPseudoMember({ email: '[email protected]' }); | ||
expect(res3).toBeFalsy(); | ||
}); | ||
|
||
it('check successfully member is pseudonymized for true values', () => { | ||
const res3 = isPseudoMember({ email: '[email protected]' }); | ||
const res3 = isPseudoMember({ type: MemberType.Guest }); | ||
expect(res3).toBeTruthy(); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters