Skip to content

Commit

Permalink
chore(NUM-2294): fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
axelsiebert committed Mar 22, 2024
1 parent 73e4fa9 commit 61210c4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/app/core/services/attachment/attachment.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
HttpResponse,
} from '@angular/common/http'
import { TestBed } from '@angular/core/testing'
import { firstValueFrom, of, skip } from 'rxjs'
import { firstValueFrom, of, skip, throwError } from 'rxjs'

Check warning on line 25 in src/app/core/services/attachment/attachment.service.spec.ts

View workflow job for this annotation

GitHub Actions / test_and_scan

'skip' is defined but never used. Allowed unused vars must match /^_/u
import { AppConfigService } from 'src/app/config/app-config.service'
import { AttachmentUploadProgress } from 'src/app/shared/models/attachment/attachment-upload-progress.interface'
import { AttachmentUploadStatus } from 'src/app/shared/models/attachment/attachment-upload-status.enum'
Expand Down Expand Up @@ -234,17 +234,22 @@ describe('AttachmentService', () => {
it('should set progress to error on http error response', async () => {
jest
.spyOn(httpMockClient, 'post')
.mockReturnValue(
of({ status: 404, type: HttpEventType.Response } as HttpEvent<HttpEventType.Response>)
.mockReturnValue(throwError(() => new HttpErrorResponse({ status: 404 })))
try {
await firstValueFrom(
service.uploadAttachment(
3,
new File([attachmentContentMock1], 'test3'),
'Third test file'
)
)
await firstValueFrom(
service.uploadAttachment(3, new File([attachmentContentMock1], 'test3'), 'Third test file')
)
const lastProgress = await firstValueFrom(service.uploadProgressObservable$)
expect(lastProgress).toEqual({
percentage: 0,
status: AttachmentUploadStatus.ERROR,
} as AttachmentUploadProgress)
} catch {
const lastProgress = await firstValueFrom(service.uploadProgressObservable$)
expect(lastProgress).toEqual({
percentage: 0,
status: AttachmentUploadStatus.ERROR,
} as AttachmentUploadProgress)
}
})

it('should throw all other errors', async () => {
Expand Down

0 comments on commit 61210c4

Please sign in to comment.