@@ -23,6 +23,7 @@ import {
2323 createSuccessfulRemoteDataObject$ ,
2424} from '../shared/remote-data.utils' ;
2525import {
26+ MATOMO_ENABLED ,
2627 MATOMO_SITE_ID ,
2728 MATOMO_TRACKER_URL ,
2829 MatomoService ,
@@ -84,6 +85,9 @@ describe('MatomoService', () => {
8485 configService . findByPropertyName . withArgs ( MATOMO_TRACKER_URL ) . and . returnValue (
8586 createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ 'http://matomo' ] } ) ) ,
8687 ) ;
88+ configService . findByPropertyName . withArgs ( MATOMO_ENABLED ) . and . returnValue (
89+ createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ 'true' ] } ) ) ,
90+ ) ;
8791 configService . findByPropertyName . withArgs ( MATOMO_SITE_ID ) . and . returnValue (
8892 createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ '1' ] } ) ) ) ;
8993 orejimeService . getSavedPreferences . and . returnValue ( of ( { matomo : true } ) ) ;
@@ -102,6 +106,9 @@ describe('MatomoService', () => {
102106 configService . findByPropertyName . withArgs ( MATOMO_TRACKER_URL ) . and . returnValue (
103107 createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ 'http://example.com' ] } ) ) ,
104108 ) ;
109+ configService . findByPropertyName . withArgs ( MATOMO_ENABLED ) . and . returnValue (
110+ createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ 'true' ] } ) ) ,
111+ ) ;
105112 configService . findByPropertyName . withArgs ( MATOMO_SITE_ID ) . and . returnValue (
106113 createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ '1' ] } ) ) ) ;
107114 orejimeService . getSavedPreferences . and . returnValue ( of ( { matomo : true } ) ) ;
@@ -123,6 +130,24 @@ describe('MatomoService', () => {
123130 expect ( matomoInitializer . initializeTracker ) . not . toHaveBeenCalled ( ) ;
124131 } ) ;
125132
133+ it ( 'should not initialize tracker if matomo is disabled' , ( ) => {
134+ environment . production = true ;
135+ environment . matomo = { trackerUrl : '' } ;
136+ configService . findByPropertyName . withArgs ( MATOMO_TRACKER_URL ) . and . returnValue (
137+ createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ 'http://example.com' ] } ) ) ,
138+ ) ;
139+ configService . findByPropertyName . withArgs ( MATOMO_ENABLED ) . and . returnValue (
140+ createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ 'false' ] } ) ) ,
141+ ) ;
142+ configService . findByPropertyName . withArgs ( MATOMO_SITE_ID ) . and . returnValue (
143+ createSuccessfulRemoteDataObject$ ( Object . assign ( new ConfigurationProperty ( ) , { values : [ '1' ] } ) ) ) ;
144+ orejimeService . getSavedPreferences . and . returnValue ( of ( { matomo : true } ) ) ;
145+
146+ service . init ( ) ;
147+
148+ expect ( matomoInitializer . initializeTracker ) . not . toHaveBeenCalled ( ) ;
149+ } ) ;
150+
126151 describe ( 'with visitorId set' , ( ) => {
127152 beforeEach ( ( ) => {
128153 matomoTracker . getVisitorId . and . returnValue ( Promise . resolve ( '12345' ) ) ;
0 commit comments