mirror of
https://github.com/bitwarden/browser
synced 2026-01-30 16:23:53 +00:00
Fix type issues
This commit is contained in:
@@ -17,7 +17,7 @@ export abstract class CipherSdkService {
|
||||
cipherView: CipherView,
|
||||
userId: UserId,
|
||||
orgAdmin?: boolean,
|
||||
): Promise<CipherView | void>;
|
||||
): Promise<CipherView | undefined>;
|
||||
|
||||
/**
|
||||
* Updates a cipher on the server using the SDK.
|
||||
@@ -33,5 +33,5 @@ export abstract class CipherSdkService {
|
||||
userId: UserId,
|
||||
originalCipherView?: CipherView,
|
||||
orgAdmin?: boolean,
|
||||
): Promise<CipherView>;
|
||||
): Promise<CipherView | undefined>;
|
||||
}
|
||||
|
||||
@@ -106,28 +106,24 @@ describe("DefaultCipherSdkService", () => {
|
||||
expect(result?.name).toBe(cipherView.name);
|
||||
});
|
||||
|
||||
it("should return void and log error when SDK client is not available", async () => {
|
||||
it("should throw error and log when SDK client is not available", async () => {
|
||||
sdkService.userClient$.mockReturnValue(of(null));
|
||||
const cipherView = new CipherView();
|
||||
cipherView.name = "Test Cipher";
|
||||
|
||||
const result = await cipherSdkService.createWithServer(cipherView, userId);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
await expect(cipherSdkService.createWithServer(cipherView, userId)).rejects.toThrow();
|
||||
expect(logService.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Failed to create cipher"),
|
||||
);
|
||||
});
|
||||
|
||||
it("should return void and log error when SDK throws an error", async () => {
|
||||
it("should throw error and log when SDK throws an error", async () => {
|
||||
const cipherView = new CipherView();
|
||||
cipherView.name = "Test Cipher";
|
||||
|
||||
mockCiphersSdk.create.mockRejectedValue(new Error("SDK error"));
|
||||
|
||||
const result = await cipherSdkService.createWithServer(cipherView, userId);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
await expect(cipherSdkService.createWithServer(cipherView, userId)).rejects.toThrow();
|
||||
expect(logService.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Failed to create cipher"),
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ export class DefaultCipherSdkService implements CipherSdkService {
|
||||
cipherView: CipherView,
|
||||
userId: UserId,
|
||||
orgAdmin?: boolean,
|
||||
): Promise<CipherView> {
|
||||
): Promise<CipherView | undefined> {
|
||||
return await firstValueFrom(
|
||||
this.sdkService.userClient$(userId).pipe(
|
||||
switchMap(async (sdk) => {
|
||||
@@ -48,7 +48,7 @@ export class DefaultCipherSdkService implements CipherSdkService {
|
||||
userId: UserId,
|
||||
originalCipherView?: CipherView,
|
||||
orgAdmin?: boolean,
|
||||
): Promise<CipherView> {
|
||||
): Promise<CipherView | undefined> {
|
||||
return await firstValueFrom(
|
||||
this.sdkService.userClient$(userId).pipe(
|
||||
switchMap(async (sdk) => {
|
||||
|
||||
Reference in New Issue
Block a user