1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

init observable on service (#8577)

This commit is contained in:
Jake Fink 2024-04-02 11:23:35 -04:00 committed by GitHub
parent af5f45443d
commit 2e6d977ef1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import { mock } from "jest-mock-extended";
import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response"; import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response";
import { AuthRequestPushNotification } from "@bitwarden/common/models/response/notification.response";
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service"; import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service"; import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
@ -30,6 +31,22 @@ describe("AuthRequestService", () => {
mockPrivateKey = new Uint8Array(64); mockPrivateKey = new Uint8Array(64);
}); });
describe("authRequestPushNotification$", () => {
it("should emit when sendAuthRequestPushNotification is called", () => {
const notification = {
id: "PUSH_NOTIFICATION",
userId: "USER_ID",
} as AuthRequestPushNotification;
const spy = jest.fn();
sut.authRequestPushNotification$.subscribe(spy);
sut.sendAuthRequestPushNotification(notification);
expect(spy).toHaveBeenCalledWith("PUSH_NOTIFICATION");
});
});
describe("approveOrDenyAuthRequest", () => { describe("approveOrDenyAuthRequest", () => {
beforeEach(() => { beforeEach(() => {
cryptoService.rsaEncrypt.mockResolvedValue({ cryptoService.rsaEncrypt.mockResolvedValue({

View File

@ -22,7 +22,9 @@ export class AuthRequestService implements AuthRequestServiceAbstraction {
private cryptoService: CryptoService, private cryptoService: CryptoService,
private apiService: ApiService, private apiService: ApiService,
private stateService: StateService, private stateService: StateService,
) {} ) {
this.authRequestPushNotification$ = this.authRequestPushNotificationSubject.asObservable();
}
async approveOrDenyAuthRequest( async approveOrDenyAuthRequest(
approve: boolean, approve: boolean,