Skip to content

Commit

Permalink
test: test if current ASN is displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
darmiel committed May 12, 2024
1 parent a046a6e commit 9429229
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ describe('StatisticsWidgetComponent', () => {
expect(req.request.method).toEqual('GET')
})

it('should call api next_asn endpoint', () => {
const req = httpTestingController.expectOne(
`${environment.apiBaseUrl}documents/next_asn/`
)
expect(req.request.method).toEqual('GET')
})

it('should reload after doc is consumed', () => {
const reloadSpy = jest.spyOn(component, 'reload')
fileStatusSubject.next(new FileStatus())
Expand Down Expand Up @@ -189,4 +196,34 @@ describe('StatisticsWidgetComponent', () => {
'Other(0.9%)'
)
})

it('should display the next ASN - 1', () => {
const mockNextASNResponse = 123

const req = httpTestingController.expectOne(
`${environment.apiBaseUrl}documents/next_asn/`
)

req.flush(mockNextASNResponse)
fixture.detectChanges()

expect(fixture.nativeElement.textContent.replace(/\s/g, '')).toContain(
'CurrentASN:122'
)
})

it('should not display the next ASN if it is not available', () => {
const mockNextASNResponse = 1

const req = httpTestingController.expectOne(
`${environment.apiBaseUrl}documents/next_asn/`
)

req.flush(mockNextASNResponse)
fixture.detectChanges()

expect(fixture.nativeElement.textContent.replace(/\s/g, '')).not.toContain(
'CurrentASN:'
)
})
})

0 comments on commit 9429229

Please sign in to comment.