Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Oluwateniayomi authored and Oluwateniayomi committed Jan 8, 2025
1 parent b70a0d2 commit 4baed5b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/App/User/user.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,69 +144,69 @@ describe('UserService', () => {
describe('createProfile', () => {
it('should return false if validateEnsAddr returns false', async () => {
jest.spyOn(userService, 'validateEnsAddr').mockResolvedValueOnce(false)

const result = await userService.createProfile(
'{"id": "0X5456AFEA3AA035088FE1F9AA36509B320360A89E"}',
'token',
)

expect(result).toBe(false)
})

it('should create and return a new profile if it does not exist', async () => {
jest.spyOn(userService, 'validateEnsAddr').mockResolvedValueOnce(true)
mockQueryBuilder.getOne.mockResolvedValueOnce(null)
mockQueryBuilder.getRawOne.mockResolvedValueOnce(null)

const result = await userService.createProfile(
JSON.stringify(profileData),
'token',
)

expect(result).toEqual({})
})

it('should update and return the profile if it exists', async () => {
jest.spyOn(userService, 'validateEnsAddr').mockResolvedValueOnce(true)
mockQueryBuilder.getOne.mockResolvedValueOnce({
id: '0X5456AFEA3AA035088FE1F9AA36509B320360A89E',
})

const result = await userService.createProfile(
JSON.stringify(profileData),
'token',
)

expect(result).toEqual({
id: '0X5456AFEA3AA035088FE1F9AA36509B320360A89E',
})
})

it('should create a new profile and user if neither exists', async () => {
jest.spyOn(userService, 'validateEnsAddr').mockResolvedValueOnce(true)
mockQueryBuilder.getOne.mockResolvedValueOnce(null)
mockQueryBuilder.getRawOne.mockResolvedValueOnce(null)

const result = await userService.createProfile(
JSON.stringify(profileData),
'token',
)

expect(result).toEqual({})
})

it('should create a new user if profile exists but user does not', async () => {
jest.spyOn(userService, 'validateEnsAddr').mockResolvedValueOnce(true)
mockQueryBuilder.getOne.mockResolvedValueOnce({
id: '0X5456AFEA3AA035088FE1F9AA36509B320360A89E',
})
mockQueryBuilder.getRawOne.mockResolvedValueOnce(null)

const result = await userService.createProfile(
JSON.stringify(profileData),
'token',
)

expect(result).toEqual({
id: '0X5456AFEA3AA035088FE1F9AA36509B320360A89E',
})
Expand All @@ -220,7 +220,7 @@ describe('UserService', () => {
mockRepository.findOne
.mockResolvedValueOnce(null)
.mockResolvedValueOnce(null)

await userService.createProfile(JSON.stringify(profileData), 'token')
expect(mockQueryBuilder.where).toHaveBeenCalledWith(
'LOWER(id) = LOWER(:id)',
Expand Down

0 comments on commit 4baed5b

Please sign in to comment.