14
14
* limitations under the License.
15
15
*/
16
16
17
- import { TestBed , fakeAsync , tick } from "@angular/core/testing" ;
17
+ import { TestBed } from "@angular/core/testing" ;
18
18
import { By } from "@angular/platform-browser" ;
19
19
import { BehaviorSubject } from "rxjs" ;
20
20
@@ -80,13 +80,14 @@ function configureComponentTest({
80
80
}
81
81
82
82
describe ( "TermsAndPrivacyComponent" , ( ) => {
83
- it ( "renders component with terms and privacy links" , fakeAsync ( ( ) => {
83
+ it ( "renders component with terms and privacy links" , async ( ) => {
84
84
const { fixture } = configureComponentTest ( {
85
85
tosUrl : "https://example.com/terms" ,
86
86
privacyPolicyUrl : "https://example.com/privacy" ,
87
87
} ) ;
88
88
89
- tick ( ) ;
89
+ // Wait for any async operations to complete
90
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ;
90
91
fixture . detectChanges ( ) ;
91
92
92
93
const container = fixture . debugElement . query ( By . css ( ".text-text-muted" ) ) ;
@@ -105,28 +106,30 @@ describe("TermsAndPrivacyComponent", () => {
105
106
const privacyLink = fixture . debugElement . query ( By . css ( 'a[href="https://example.com/privacy"]' ) ) ;
106
107
expect ( privacyLink ) . toBeTruthy ( ) ;
107
108
expect ( privacyLink . nativeElement . textContent . trim ( ) ) . toBe ( "Privacy Policy" ) ;
108
- } ) ) ;
109
+ } ) ;
109
110
110
- it ( "does not render when both tosUrl and privacyPolicyUrl are not provided" , fakeAsync ( ( ) => {
111
+ it ( "does not render when both tosUrl and privacyPolicyUrl are not provided" , async ( ) => {
111
112
const { fixture } = configureComponentTest ( {
112
113
tosUrl : null ,
113
114
privacyPolicyUrl : null ,
114
115
} ) ;
115
116
116
- tick ( ) ;
117
+ // Wait for any async operations to complete
118
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ;
117
119
fixture . detectChanges ( ) ;
118
120
119
121
const container = fixture . debugElement . query ( By . css ( ".text-text-muted" ) ) ;
120
122
expect ( container ) . toBeFalsy ( ) ;
121
- } ) ) ;
123
+ } ) ;
122
124
123
- it ( "renders with tosUrl when privacyPolicyUrl is not provided" , fakeAsync ( ( ) => {
125
+ it ( "renders with tosUrl when privacyPolicyUrl is not provided" , async ( ) => {
124
126
const { fixture } = configureComponentTest ( {
125
127
tosUrl : "https://example.com/terms" ,
126
128
privacyPolicyUrl : null ,
127
129
} ) ;
128
130
129
- tick ( ) ;
131
+ // Wait for any async operations to complete
132
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ;
130
133
fixture . detectChanges ( ) ;
131
134
132
135
const container = fixture . debugElement . query ( By . css ( ".text-text-muted" ) ) ;
@@ -137,15 +140,16 @@ describe("TermsAndPrivacyComponent", () => {
137
140
138
141
const privacyLink = fixture . debugElement . query ( By . css ( 'a[href="https://example.com/privacy"]' ) ) ;
139
142
expect ( privacyLink ) . toBeFalsy ( ) ;
140
- } ) ) ;
143
+ } ) ;
141
144
142
- it ( "renders with privacyPolicyUrl when tosUrl is not provided" , fakeAsync ( ( ) => {
145
+ it ( "renders with privacyPolicyUrl when tosUrl is not provided" , async ( ) => {
143
146
const { fixture } = configureComponentTest ( {
144
147
tosUrl : null ,
145
148
privacyPolicyUrl : "https://example.com/privacy" ,
146
149
} ) ;
147
150
148
- tick ( ) ;
151
+ // Wait for any async operations to complete
152
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ;
149
153
fixture . detectChanges ( ) ;
150
154
151
155
const container = fixture . debugElement . query ( By . css ( ".text-text-muted" ) ) ;
@@ -156,17 +160,18 @@ describe("TermsAndPrivacyComponent", () => {
156
160
157
161
const privacyLink = fixture . debugElement . query ( By . css ( 'a[href="https://example.com/privacy"]' ) ) ;
158
162
expect ( privacyLink ) . toBeTruthy ( ) ;
159
- } ) ) ;
163
+ } ) ;
160
164
161
- it ( "uses custom template text when provided" , fakeAsync ( ( ) => {
165
+ it ( "uses custom template text when provided" , async ( ) => {
162
166
const { fixture, mockFirebaseUI } = configureComponentTest ( {
163
167
tosUrl : "https://example.com/terms" ,
164
168
privacyPolicyUrl : "https://example.com/privacy" ,
165
169
} ) ;
166
170
167
171
mockFirebaseUI . setTranslation ( "messages" , "termsAndPrivacy" , "Custom template with {tos} and {privacy}" ) ;
168
172
169
- tick ( ) ;
173
+ // Wait for any async operations to complete
174
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ;
170
175
fixture . detectChanges ( ) ;
171
176
172
177
const container = fixture . debugElement . query ( By . css ( ".text-text-muted" ) ) ;
@@ -176,5 +181,5 @@ describe("TermsAndPrivacyComponent", () => {
176
181
expect ( textContent ) . toContain ( "Custom template with" ) ;
177
182
expect ( textContent ) . toContain ( "Terms of Service" ) ;
178
183
expect ( textContent ) . toContain ( "Privacy Policy" ) ;
179
- } ) ) ;
184
+ } ) ;
180
185
} ) ;
0 commit comments