-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* first commit * add some tests * add test cases and services * add usecases and test cases * fix importing * add type in uc * fix import * implement entity, domain, mapper and repo for rocketChat * fix most of issue form review * add some test,additional status, limit ... * implement rocketChat User deletion * add service to module * small fixes during review * implement deletion rocketChat user in KNL deletion module * small fixes * changing limit parameter and changing in useCases * delete 3 lines of code * Update apps/server/src/modules/deletion/uc/deletion-request.uc.ts Co-authored-by: Sergej Hoffmann <[email protected]> * Update apps/server/src/modules/deletion/uc/deletion-request.uc.spec.ts Co-authored-by: Sergej Hoffmann <[email protected]> * small fixes * Update apps/server/src/modules/deletion/uc/deletion-request.uc.spec.ts Co-authored-by: Sergej Hoffmann <[email protected]> * import fix --------- Co-authored-by: Sergej Hoffmann <[email protected]>
- Loading branch information
1 parent
3cf0fd5
commit e82f2d7
Showing
24 changed files
with
717 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './rocket-chat-user.do'; |
67 changes: 67 additions & 0 deletions
67
apps/server/src/modules/rocketchat-user/domain/rocket-chat-user.do.spec.ts
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,67 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { RocketChatUser } from './rocket-chat-user.do'; | ||
import { rocketChatUserFactory } from './testing/rocket-chat-user.factory'; | ||
|
||
describe(RocketChatUser.name, () => { | ||
describe('constructor', () => { | ||
describe('When constructor is called', () => { | ||
it('should create a rocketChatUser by passing required properties', () => { | ||
const domainObject: RocketChatUser = rocketChatUserFactory.build(); | ||
|
||
expect(domainObject instanceof RocketChatUser).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe('when passed a valid id', () => { | ||
const setup = () => { | ||
const domainObject: RocketChatUser = rocketChatUserFactory.build(); | ||
|
||
return { domainObject }; | ||
}; | ||
|
||
it('should set the id', () => { | ||
const { domainObject } = setup(); | ||
|
||
const rocketChatUserObject: RocketChatUser = new RocketChatUser(domainObject); | ||
|
||
expect(rocketChatUserObject.id).toEqual(domainObject.id); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('getters', () => { | ||
describe('When getters are used', () => { | ||
const setup = () => { | ||
const props = { | ||
id: new ObjectId().toHexString(), | ||
userId: new ObjectId().toHexString(), | ||
username: 'Test.User.shls', | ||
rcId: 'JfMJXua6t29KYXdDc', | ||
authToken: 'OL8e5YCZHy3agGnLS-gHAx1wU4ZCG8-DXU_WZnUxUu6', | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}; | ||
|
||
const rocketChatUserDo = new RocketChatUser(props); | ||
|
||
return { props, rocketChatUserDo }; | ||
}; | ||
|
||
it('getters should return proper values', () => { | ||
const { props, rocketChatUserDo } = setup(); | ||
|
||
const gettersValues = { | ||
id: rocketChatUserDo.id, | ||
userId: rocketChatUserDo.userId, | ||
username: rocketChatUserDo.username, | ||
rcId: rocketChatUserDo.rcId, | ||
authToken: rocketChatUserDo.authToken, | ||
createdAt: rocketChatUserDo.createdAt, | ||
updatedAt: rocketChatUserDo.updatedAt, | ||
}; | ||
|
||
expect(gettersValues).toEqual(props); | ||
}); | ||
}); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
apps/server/src/modules/rocketchat-user/domain/rocket-chat-user.do.ts
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,37 @@ | ||
import { EntityId } from '@shared/domain/types'; | ||
import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object'; | ||
|
||
export interface RocketChatUserProps extends AuthorizableObject { | ||
userId: EntityId; | ||
username: string; | ||
rcId: string; | ||
authToken?: string; | ||
createdAt?: Date; | ||
updatedAt?: Date; | ||
} | ||
|
||
export class RocketChatUser extends DomainObject<RocketChatUserProps> { | ||
get userId(): EntityId { | ||
return this.props.userId; | ||
} | ||
|
||
get username(): string { | ||
return this.props.username; | ||
} | ||
|
||
get rcId(): string { | ||
return this.props.rcId; | ||
} | ||
|
||
get authToken(): string | undefined { | ||
return this.props.authToken; | ||
} | ||
|
||
get createdAt(): Date | undefined { | ||
return this.props.createdAt; | ||
} | ||
|
||
get updatedAt(): Date | undefined { | ||
return this.props.updatedAt; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
apps/server/src/modules/rocketchat-user/domain/testing/index.ts
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 @@ | ||
export * from './rocket-chat-user.factory'; |
18 changes: 18 additions & 0 deletions
18
apps/server/src/modules/rocketchat-user/domain/testing/rocket-chat-user.factory.ts
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,18 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { BaseFactory } from '@shared/testing'; | ||
import { RocketChatUser, RocketChatUserProps } from '../rocket-chat-user.do'; | ||
|
||
export const rocketChatUserFactory = BaseFactory.define<RocketChatUser, RocketChatUserProps>( | ||
RocketChatUser, | ||
({ sequence }) => { | ||
return { | ||
id: new ObjectId().toHexString(), | ||
userId: new ObjectId().toHexString(), | ||
username: `username-${sequence}`, | ||
rcId: `rcId-${sequence}`, | ||
authToken: `aythToken-${sequence}`, | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}; | ||
} | ||
); |
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 @@ | ||
export * from './rocket-chat-user.entity'; |
61 changes: 61 additions & 0 deletions
61
apps/server/src/modules/rocketchat-user/entity/rocket-chat-user.entity.spec.ts
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,61 @@ | ||
import { setupEntities } from '@shared/testing'; | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { RocketChatUserEntity } from '@src/modules/rocketchat-user/entity'; | ||
|
||
describe(RocketChatUserEntity.name, () => { | ||
beforeAll(async () => { | ||
await setupEntities(); | ||
}); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
const setup = () => { | ||
const props = { | ||
id: new ObjectId().toHexString(), | ||
userId: new ObjectId(), | ||
username: 'Test.User.shls', | ||
rcId: 'JfMJXua6t29KYXdDc', | ||
authToken: 'OL8e5YCZHy3agGnLS-gHAx1wU4ZCG8-DXU_WZnUxUu6', | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}; | ||
|
||
return { props }; | ||
}; | ||
|
||
describe('constructor', () => { | ||
describe('When constructor is called', () => { | ||
it('should throw an error by empty constructor', () => { | ||
// @ts-expect-error: Test case | ||
const test = () => new RocketChatUserEntity(); | ||
expect(test).toThrow(); | ||
}); | ||
|
||
it('should create a rocketChatUser by passing required properties', () => { | ||
const { props } = setup(); | ||
const entity: RocketChatUserEntity = new RocketChatUserEntity(props); | ||
|
||
expect(entity instanceof RocketChatUserEntity).toEqual(true); | ||
}); | ||
|
||
it(`should return a valid object with fields values set from the provided complete props object`, () => { | ||
const { props } = setup(); | ||
const entity: RocketChatUserEntity = new RocketChatUserEntity(props); | ||
|
||
const entityProps = { | ||
id: entity.id, | ||
userId: entity.userId, | ||
username: entity.username, | ||
rcId: entity.rcId, | ||
authToken: entity.authToken, | ||
createdAt: entity.createdAt, | ||
updatedAt: entity.updatedAt, | ||
}; | ||
|
||
expect(entityProps).toEqual(props); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.