@@ -78,8 +78,27 @@ describe('MatomoService', () => {
7878 expect ( matomoTracker . forgetConsentGiven ) . toHaveBeenCalled ( ) ;
7979 } ) ;
8080
81- it ( 'should initialize tracker with correct parameters in production ' , ( ) => {
81+ it ( 'should initialize tracker with values from angular configuration ' , ( ) => {
8282 environment . production = true ;
83+ environment . matomo = { trackerUrl : 'http://localhost:80801' } ;
84+ configService . findByPropertyName . withArgs ( MATOMO_TRACKER_URL ) . and . returnValue (
85+ createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ 'http://matomo' ] } ) ) ,
86+ ) ;
87+ configService . findByPropertyName . withArgs ( MATOMO_SITE_ID ) . and . returnValue (
88+ createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ '1' ] } ) ) ) ;
89+ orejimeService . getSavedPreferences . and . returnValue ( of ( { matomo : true } ) ) ;
90+ service . init ( ) ;
91+
92+ expect ( matomoTracker . setConsentGiven ) . toHaveBeenCalled ( ) ;
93+ expect ( matomoInitializer . initializeTracker ) . toHaveBeenCalledWith ( {
94+ siteId : '1' ,
95+ trackerUrl : 'http://localhost:80801' ,
96+ } ) ;
97+ } ) ;
98+
99+ it ( 'should initialize tracker with REST configuration correct parameters in production' , ( ) => {
100+ environment . production = true ;
101+ environment . matomo = { trackerUrl : '' } ;
83102 configService . findByPropertyName . withArgs ( MATOMO_TRACKER_URL ) . and . returnValue (
84103 createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ 'http://example.com' ] } ) ) ,
85104 ) ;
0 commit comments