Skip to content

Commit

Permalink
init observable on service (#8577)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlf0dev committed Apr 2, 2024
1 parent af5f454 commit 2e6d977
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { mock } from "jest-mock-extended";

import { ApiService } from "@bitwarden/common/abstractions/api.service";
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 { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
Expand Down Expand Up @@ -30,6 +31,22 @@ describe("AuthRequestService", () => {
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", () => {
beforeEach(() => {
cryptoService.rsaEncrypt.mockResolvedValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export class AuthRequestService implements AuthRequestServiceAbstraction {
private cryptoService: CryptoService,
private apiService: ApiService,
private stateService: StateService,
) {}
) {
this.authRequestPushNotification$ = this.authRequestPushNotificationSubject.asObservable();
}

async approveOrDenyAuthRequest(
approve: boolean,
Expand Down

0 comments on commit 2e6d977

Please sign in to comment.