mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-14 18:46:52 +01:00
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
|
|
import {
|
||
|
|
HttpClientTestingModule,
|
||
|
|
HttpTestingController,
|
||
|
|
} from '@angular/common/http/testing'
|
||
|
|
import { Subscription } from 'rxjs'
|
||
|
|
import { TestBed } from '@angular/core/testing'
|
||
|
|
import { environment } from 'src/environments/environment'
|
||
|
|
import { LogService } from './log.service'
|
||
|
|
|
||
|
|
let httpTestingController: HttpTestingController
|
||
|
|
let service: LogService
|
||
|
|
let subscription: Subscription
|
||
|
|
const endpoint = 'logs'
|
||
|
|
|
||
|
|
describe('LogService', () => {
|
||
|
|
beforeEach(() => {
|
||
|
|
TestBed.configureTestingModule({
|
||
|
|
providers: [LogService],
|
||
|
|
imports: [HttpClientTestingModule],
|
||
|
|
})
|
||
|
|
|
||
|
|
httpTestingController = TestBed.inject(HttpTestingController)
|
||
|
|
service = TestBed.inject(LogService)
|
||
|
|
})
|
||
|
|
|
||
|
|
afterEach(() => {
|
||
|
|
subscription?.unsubscribe()
|
||
|
|
httpTestingController.verify()
|
||
|
|
})
|
||
|
|
|
||
|
|
it('should call correct api endpoint on logs list', () => {
|
||
|
|
subscription = service.list().subscribe()
|
||
|
|
const req = httpTestingController.expectOne(
|
||
|
|
`${environment.apiBaseUrl}${endpoint}/`
|
||
|
|
)
|
||
|
|
expect(req.request.method).toEqual('GET')
|
||
|
|
})
|
||
|
|
|
||
|
|
it('should call correct api endpoint on logs get', () => {
|
||
|
|
const id: string = 'mail'
|
||
|
|
subscription = service.get(id).subscribe()
|
||
|
|
const req = httpTestingController.expectOne(
|
||
|
|
`${environment.apiBaseUrl}${endpoint}/${id}/`
|
||
|
|
)
|
||
|
|
expect(req.request.method).toEqual('GET')
|
||
|
|
})
|
||
|
|
})
|