@@ -2,6 +2,8 @@ import { TestBed, waitForAsync } from '@angular/core/testing';
2
2
import { Platform } from '@ionic/angular' ;
3
3
import { SharedTestingModule } from '../shared-testing.module' ;
4
4
5
+ import { AFEvent } from 'appsflyer-capacitor-plugin' ;
6
+ import { CCamCustomEventType } from './apps-flyer-enums' ;
5
7
import { AppsFlyerService } from './apps-flyer.service' ;
6
8
7
9
describe ( 'AppsFlyerService' , ( ) => {
@@ -32,4 +34,21 @@ describe('AppsFlyerService', () => {
32
34
it ( 'should be created' , ( ) => {
33
35
expect ( service ) . toBeTruthy ( ) ;
34
36
} ) ;
37
+
38
+ it ( 'should log camera shutter event through Appsflyer.logEvent method' , async ( ) => {
39
+ const expectedEvent : AFEvent = {
40
+ eventName : CCamCustomEventType . CCAM_TRY_CLICK_CAMERA_SHUTTER ,
41
+ } ;
42
+ // NOTE: We're accessing a private method here for testing purposes only.
43
+ // TypeScript doesn't enforce private/protected visibility at runtime, only at compile time.
44
+ // This is generally not recommended as it can lead to fragile tests and breaks encapsulation.
45
+ // However, in this case, we need to ensure that the private method 'logEvent' is called with
46
+ // the correct parameters.
47
+ const logEventSpy = spyOn ( service as any , 'logEvent' ) ;
48
+
49
+ await service . logCameraShutterEvent ( ) ;
50
+
51
+ expect ( logEventSpy ) . toHaveBeenCalledWith ( expectedEvent ) ;
52
+ expect ( logEventSpy ) . toHaveBeenCalledTimes ( 1 ) ;
53
+ } ) ;
35
54
} ) ;
0 commit comments