Skip to content

Commit

Permalink
fix: changed test
Browse files Browse the repository at this point in the history
  • Loading branch information
janrtvld committed Mar 31, 2022
1 parent 27135cc commit 4f19ce6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1088,21 +1088,22 @@ describe('CredentialService', () => {
})

describe('deleteCredential', () => {
it('should delete credential from repository', async () => {
it('should call delete from repository', async () => {
const credential = mockCredentialRecord()
mockFunction(credentialRepository.getById).mockReturnValue(Promise.resolve(credential))

const repositoryDeleteSpy = jest.spyOn(credentialRepository, 'delete')
await credentialService.deleteById(credential.id)
expect(repositoryDeleteSpy).toBeCalledWith(credential)
expect(repositoryDeleteSpy).toHaveBeenNthCalledWith(1, credential)
})

it('deleteFromWallet parameter should call deleteCredential in indyHolderService', async () => {
const deleteCredentialMock = indyHolderService.deleteCredential as jest.Mock<Promise<void>, [string]>
const credential = mockCredentialRecord()
mockFunction(credentialRepository.getById).mockReturnValue(Promise.resolve(credential))
const indyHolderServiceDeleteCredentialSpy = jest.spyOn(indyHolderService, 'deleteCredential')

await credentialService.deleteById(credential.id, true)
expect(indyHolderServiceDeleteCredentialSpy).toBeCalledWith(credential.id)
expect(deleteCredentialMock).toHaveBeenNthCalledWith(1, credential.id)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ export class CredentialService {
*
* @param credentialId the credential record id
*/
public async deleteById(credentialId: string, deleteFromWallet?: boolean) {
public async deleteById(credentialId: string, deleteFromWallet?: boolean): Promise<void> {
const credentialRecord = await this.getById(credentialId)

if (deleteFromWallet) {
Expand Down

0 comments on commit 4f19ce6

Please sign in to comment.