fix: fix observable

This commit is contained in:
2025-01-31 03:23:45 +08:00
parent 733b697ee2
commit 316361bd3c
45 changed files with 1084 additions and 1355 deletions

View File

@@ -103,9 +103,8 @@ describe(`AuthHttpInterceptor`, () => {
true
);
httpClient.get(actionUrl).subscribe((response) => {
expect(response).toBeTruthy();
});
const response = await lastValueFrom(httpClient.get(actionUrl));
expect(response).toBeTruthy();
const httpRequest = httpTestingController.expectOne(actionUrl);
@@ -130,9 +129,8 @@ describe(`AuthHttpInterceptor`, () => {
true
);
httpClient.get(actionUrl).subscribe((response) => {
expect(response).toBeTruthy();
});
const response = await lastValueFrom(httpClient.get(actionUrl));
expect(response).toBeTruthy();
const httpRequest = httpTestingController.expectOne(actionUrl);
@@ -159,9 +157,8 @@ describe(`AuthHttpInterceptor`, () => {
'thisIsAToken'
);
httpClient.get(actionUrl).subscribe((response) => {
expect(response).toBeTruthy();
});
const response = await lastValueFrom(httpClient.get(actionUrl));
expect(response).toBeTruthy();
const httpRequest = httpTestingController.expectOne(actionUrl);
@@ -185,9 +182,8 @@ describe(`AuthHttpInterceptor`, () => {
true
);
httpClient.get(actionUrl).subscribe((response) => {
expect(response).toBeTruthy();
});
const response = await lastValueFrom(httpClient.get(actionUrl));
expect(response).toBeTruthy();
const httpRequest = httpTestingController.expectOne(actionUrl);
@@ -212,9 +208,8 @@ describe(`AuthHttpInterceptor`, () => {
);
vi.spyOn(authStateService, 'getAccessToken').mockReturnValue('');
httpClient.get(actionUrl).subscribe((response) => {
expect(response).toBeTruthy();
});
const response = await lastValueFrom(httpClient.get(actionUrl));
expect(response).toBeTruthy();
const httpRequest = httpTestingController.expectOne(actionUrl);
@@ -231,9 +226,8 @@ describe(`AuthHttpInterceptor`, () => {
false
);
httpClient.get(actionUrl).subscribe((response) => {
expect(response).toBeTruthy();
});
const response = await lastValueFrom(httpClient.get(actionUrl));
expect(response).toBeTruthy();
const httpRequest = httpTestingController.expectOne(actionUrl);
@@ -263,9 +257,8 @@ describe(`AuthHttpInterceptor`, () => {
matchingConfig: null,
});
httpClient.get(actionUrl).subscribe((response) => {
expect(response).toBeTruthy();
});
const response = await lastValueFrom(httpClient.get(actionUrl));
expect(response).toBeTruthy();
const httpRequest = httpTestingController.expectOne(actionUrl);
@@ -290,13 +283,11 @@ describe(`AuthHttpInterceptor`, () => {
true
);
httpClient.get(actionUrl).subscribe((response) => {
expect(response).toBeTruthy();
});
const response = await lastValueFrom(httpClient.get(actionUrl));
expect(response).toBeTruthy();
httpClient.get(actionUrl2).subscribe((response) => {
expect(response).toBeTruthy();
});
const response = await lastValueFrom(httpClient.get(actionUrl2));
expect(response).toBeTruthy();
const httpRequest = httpTestingController.expectOne(actionUrl);

View File

@@ -1,4 +1,4 @@
import {
import type {
HttpEvent,
HttpHandler,
HttpHandlerFn,
@@ -6,8 +6,8 @@ import {
HttpInterceptorFn,
HttpRequest,
} from '@ngify/http';
import { inject, Injectable } from 'injection-js';
import { Observable } from 'rxjs';
import { Injectable, inject } from 'injection-js';
import type { Observable } from 'rxjs';
import { AuthStateService } from '../auth-state/auth-state.service';
import { ConfigurationService } from '../config/config.service';
import { LoggerService } from '../logging/logger.service';