mirror of
https://github.com/bitwarden/browser
synced 2026-02-12 14:34:02 +00:00
PM-14927 removed some dependencies in spec file and used takeUntil in service
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { randomUUID } from "crypto";
|
||||
|
||||
import { fakeAsync, flush, TestBed } from "@angular/core/testing";
|
||||
import { fakeAsync, flush } from "@angular/core/testing";
|
||||
import { mock } from "jest-mock-extended";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
@@ -22,15 +22,7 @@ describe("CriticalAppsApiService", () => {
|
||||
const encryptService = mock<EncryptService>();
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
CriticalAppsApiService,
|
||||
{ provide: ApiService, useValue: apiService },
|
||||
{ provide: KeyService, useValue: keyService },
|
||||
{ provide: EncryptService, useValue: encryptService },
|
||||
],
|
||||
});
|
||||
service = TestBed.inject(CriticalAppsApiService);
|
||||
service = new CriticalAppsApiService(apiService, keyService, encryptService);
|
||||
|
||||
// reset mocks
|
||||
jest.resetAllMocks();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Injectable, OnDestroy } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { BehaviorSubject, firstValueFrom, map, Observable } from "rxjs";
|
||||
import { BehaviorSubject, firstValueFrom, map, Observable, Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||
@@ -18,9 +17,10 @@ import { KeyService } from "@bitwarden/key-management";
|
||||
export class CriticalAppsApiService implements OnDestroy {
|
||||
private orgId = new BehaviorSubject<OrganizationId | null>(null);
|
||||
private criticalAppsList = new BehaviorSubject<PasswordHealthReportApplicationsResponse[]>([]);
|
||||
private teardown = new Subject<void>();
|
||||
|
||||
private fetchOrg$ = this.orgId
|
||||
.pipe(takeUntilDestroyed())
|
||||
.pipe(takeUntil(this.teardown))
|
||||
.subscribe((orgId) => this.retrieveCriticalApps(orgId));
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
||||
Reference in New Issue
Block a user