Skip to content

Commit

Permalink
test(modules/users-profile.controller): should get user analysis test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnigos committed Dec 9, 2023
1 parent 3561f02 commit 29afeba
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/modules/users/users-profile.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
topGenresMock,
spotifyResponseWithOffsetMockFactory,
artistsMock,
analysisMock,
} from '@common/mocks'
import { SecretData } from '@modules/auth/dtos'

Expand Down Expand Up @@ -60,6 +61,7 @@ describe('UsersProfileController', () => {
topTracks: vi.fn(),
topGenres: vi.fn(),
topArtists: vi.fn(),
analysis: vi.fn(),
},
},
],
Expand Down Expand Up @@ -328,8 +330,18 @@ describe('UsersProfileController', () => {
const findOneBySpy = vi
.spyOn(usersRepository, 'findOneBy')
.mockResolvedValue(userMock)

expect(await usersProfileController.getAnalysis(id)).toEqual(userMock)
const tokenSpy = vi
.spyOn(authService, 'token')
.mockReturnValue(of(secretDataMock))
const analysisSpy = vi
.spyOn(statisticsService, 'analysis')
.mockReturnValue(of(analysisMock))

expect(await usersProfileController.getAnalysis(id)).toEqual(analysisMock)
expect(tokenSpy).toHaveBeenCalledWith({
refreshToken: userMock.refreshToken,
})
expect(analysisSpy).toHaveBeenCalledWith(accessToken)
expect(findOneBySpy).toHaveBeenCalledWith({ id })
})

Expand Down

0 comments on commit 29afeba

Please sign in to comment.