11import { mock } from "jest-mock-extended" ;
2- import { of , firstValueFrom } from "rxjs" ;
2+ import { of , firstValueFrom , BehaviorSubject } from "rxjs" ;
33
44import { ApiService } from "@bitwarden/common/abstractions/api.service" ;
55import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions" ;
@@ -24,12 +24,14 @@ describe("DefaultCipherArchiveService", () => {
2424
2525 const userId = "user-id" as UserId ;
2626 const cipherId = "123" as CipherId ;
27+ const featureFlag = new BehaviorSubject < boolean > ( true ) ;
2728
2829 beforeEach ( ( ) => {
2930 mockCipherService = mock < CipherService > ( ) ;
3031 mockApiService = mock < ApiService > ( ) ;
3132 mockBillingAccountProfileStateService = mock < BillingAccountProfileStateService > ( ) ;
3233 mockConfigService = mock < ConfigService > ( ) ;
34+ mockConfigService . getFeatureFlag$ . mockReturnValue ( featureFlag . asObservable ( ) ) ;
3335
3436 service = new DefaultCipherArchiveService (
3537 mockCipherService ,
@@ -86,7 +88,7 @@ describe("DefaultCipherArchiveService", () => {
8688 describe ( "userCanArchive$" , ( ) => {
8789 it ( "should return true when user has premium and feature flag is enabled" , async ( ) => {
8890 mockBillingAccountProfileStateService . hasPremiumFromAnySource$ . mockReturnValue ( of ( true ) ) ;
89- mockConfigService . getFeatureFlag$ . mockReturnValue ( of ( true ) ) ;
91+ featureFlag . next ( true ) ;
9092
9193 const result = await firstValueFrom ( service . userCanArchive$ ( userId ) ) ;
9294
@@ -101,7 +103,7 @@ describe("DefaultCipherArchiveService", () => {
101103
102104 it ( "should return false when feature flag is disabled" , async ( ) => {
103105 mockBillingAccountProfileStateService . hasPremiumFromAnySource$ . mockReturnValue ( of ( false ) ) ;
104- mockConfigService . getFeatureFlag$ . mockReturnValue ( of ( false ) ) ;
106+ featureFlag . next ( false ) ;
105107
106108 const result = await firstValueFrom ( service . userCanArchive$ ( userId ) ) ;
107109
@@ -111,7 +113,7 @@ describe("DefaultCipherArchiveService", () => {
111113
112114 describe ( "hasArchiveFlagEnabled$" , ( ) => {
113115 it ( "returns true when feature flag is enabled" , async ( ) => {
114- mockConfigService . getFeatureFlag$ . mockReturnValue ( of ( true ) ) ;
116+ featureFlag . next ( true ) ;
115117
116118 const result = await firstValueFrom ( service . hasArchiveFlagEnabled$ ) ;
117119
@@ -122,7 +124,7 @@ describe("DefaultCipherArchiveService", () => {
122124 } ) ;
123125
124126 it ( "returns false when feature flag is disabled" , async ( ) => {
125- mockConfigService . getFeatureFlag$ . mockReturnValue ( of ( false ) ) ;
127+ featureFlag . next ( false ) ;
126128
127129 const result = await firstValueFrom ( service . hasArchiveFlagEnabled$ ) ;
128130
0 commit comments