|
3 | 3 | * |
4 | 4 | * ping-protect-intitialize-callback.test.ts |
5 | 5 | * |
6 | | - * Copyright (c) 2024 - 2025 Ping Identity Corporation. All rights reserved. |
| 6 | + * Copyright (c) 2024 - 2026 Ping Identity Corporation. All rights reserved. |
7 | 7 | * This software may be modified and distributed under the terms |
8 | 8 | * of the MIT license. See the LICENSE file for details. |
9 | 9 | */ |
@@ -186,6 +186,80 @@ describe('PingOneProtectInitializeCallback', () => { |
186 | 186 | }); |
187 | 187 | }); |
188 | 188 |
|
| 189 | + it('should return signalsInitializationOptions directly when valid', () => { |
| 190 | + const signalsInitializationOptions = { |
| 191 | + agentIdentification: 'false', |
| 192 | + htmlGeoLocation: 'true', |
| 193 | + behavioralDataCollection: 'true', |
| 194 | + universalDeviceIdentification: 'false', |
| 195 | + option1: 'value1', |
| 196 | + disableTags: 'false', |
| 197 | + }; |
| 198 | + |
| 199 | + const callback = new PingOneProtectInitializeCallback({ |
| 200 | + type: 'PingOneProtectInitializeCallback' as CallbackType, |
| 201 | + input: [], |
| 202 | + output: [ |
| 203 | + { |
| 204 | + name: 'signalsInitializationOptions', |
| 205 | + value: signalsInitializationOptions, |
| 206 | + }, |
| 207 | + { |
| 208 | + name: 'envId', |
| 209 | + value: 'legacy-env-id-that-should-be-ignored', |
| 210 | + }, |
| 211 | + ], |
| 212 | + }); |
| 213 | + |
| 214 | + const config = callback.getConfig(); |
| 215 | + expect(config).toEqual(signalsInitializationOptions); |
| 216 | + expect(config).not.toHaveProperty('envId'); |
| 217 | + }); |
| 218 | + |
| 219 | + it('should fallback to legacy config when signalsInitializationOptions is invalid', () => { |
| 220 | + const callback = new PingOneProtectInitializeCallback({ |
| 221 | + type: 'PingOneProtectInitializeCallback' as CallbackType, |
| 222 | + input: [], |
| 223 | + output: [ |
| 224 | + { |
| 225 | + name: 'signalsInitializationOptions', |
| 226 | + value: [], |
| 227 | + }, |
| 228 | + { |
| 229 | + name: 'envId', |
| 230 | + value: '02fb4743-189a-4bc7-9d6c-a919edfe6447', |
| 231 | + }, |
| 232 | + ], |
| 233 | + }); |
| 234 | + |
| 235 | + const config = callback.getConfig(); |
| 236 | + expect(config).toMatchObject({ |
| 237 | + envId: '02fb4743-189a-4bc7-9d6c-a919edfe6447', |
| 238 | + behavioralDataCollection: true, |
| 239 | + disableTags: false, |
| 240 | + }); |
| 241 | + }); |
| 242 | + |
| 243 | + it('should fallback to legacy config when signalsInitializationOptions is missing', () => { |
| 244 | + const callback = new PingOneProtectInitializeCallback({ |
| 245 | + type: 'PingOneProtectInitializeCallback' as CallbackType, |
| 246 | + input: [], |
| 247 | + output: [ |
| 248 | + { |
| 249 | + name: 'envId', |
| 250 | + value: '02fb4743-189a-4bc7-9d6c-a919edfe6447', |
| 251 | + }, |
| 252 | + ], |
| 253 | + }); |
| 254 | + |
| 255 | + const config = callback.getConfig(); |
| 256 | + expect(config).toMatchObject({ |
| 257 | + envId: '02fb4743-189a-4bc7-9d6c-a919edfe6447', |
| 258 | + behavioralDataCollection: true, |
| 259 | + disableTags: false, |
| 260 | + }); |
| 261 | + }); |
| 262 | + |
189 | 263 | it('should test the setClientError method', () => { |
190 | 264 | const callback = new PingOneProtectInitializeCallback({ |
191 | 265 | type: 'PingOneProtectInitializeCallback' as CallbackType, |
|
0 commit comments