|
14 | 14 | * limitations under the License. |
15 | 15 | * |
16 | 16 | */ |
17 | | - |
18 | | -describe('analytics() modular', function () { |
| 17 | +describe('analytics()', function () { |
19 | 18 | beforeEach(async function () { |
20 | | - await firebase.analytics().logEvent('screen_view'); |
| 19 | + const { getAnalytics, logEvent } = analyticsModular; |
| 20 | + await logEvent(getAnalytics(), 'screen_view'); |
21 | 21 | }); |
22 | 22 |
|
23 | 23 | describe('firebase v8 compatibility', function () { |
| 24 | + beforeEach(async function beforeEachTest() { |
| 25 | + // @ts-ignore |
| 26 | + globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true; |
| 27 | + }); |
| 28 | + |
| 29 | + afterEach(async function afterEachTest() { |
| 30 | + // @ts-ignore |
| 31 | + globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false; |
| 32 | + }); |
| 33 | + |
24 | 34 | describe('logEvent()', function () { |
25 | 35 | it('log an event without parameters', async function () { |
26 | 36 | await firebase.analytics().logEvent('invertase_event'); |
@@ -549,9 +559,10 @@ describe('analytics() modular', function () { |
549 | 559 | describe('modular', function () { |
550 | 560 | describe('getAnalytics', function () { |
551 | 561 | it('pass app as argument', function () { |
| 562 | + const { getApp } = modular; |
552 | 563 | const { getAnalytics } = analyticsModular; |
553 | 564 |
|
554 | | - const analytics = getAnalytics(firebase.app()); |
| 565 | + const analytics = getAnalytics(getApp()); |
555 | 566 |
|
556 | 567 | analytics.constructor.name.should.be.equal('FirebaseAnalyticsModule'); |
557 | 568 | }); |
@@ -1133,5 +1144,29 @@ describe('analytics() modular', function () { |
1133 | 1144 | await setConsent(getAnalytics(), consentSettings); |
1134 | 1145 | }); |
1135 | 1146 | }); |
| 1147 | + |
| 1148 | + describe('getGoogleAnalyticsClientId()', function () { |
| 1149 | + it('Error for getGoogleAnalyticsClientId() on non-other platforms', async function () { |
| 1150 | + if (Platform.other) { |
| 1151 | + this.skip(); |
| 1152 | + } |
| 1153 | + try { |
| 1154 | + const { getAnalytics, getGoogleAnalyticsClientId } = analyticsModular; |
| 1155 | + await getGoogleAnalyticsClientId(getAnalytics()); |
| 1156 | + fail('Should have thrown an error'); |
| 1157 | + } catch (e) { |
| 1158 | + e.message.should.equal('getGoogleAnalyticsClientId is web-only.'); |
| 1159 | + } |
| 1160 | + }); |
| 1161 | + |
| 1162 | + it('getGoogleAnalyticsClientId() works on other platform', async function () { |
| 1163 | + const { getAnalytics, getGoogleAnalyticsClientId } = analyticsModular; |
| 1164 | + if (!Platform.other) { |
| 1165 | + this.skip(); |
| 1166 | + } |
| 1167 | + let cid = await getGoogleAnalyticsClientId(getAnalytics()); |
| 1168 | + cid.should.not.be.empty; |
| 1169 | + }); |
| 1170 | + }); |
1136 | 1171 | }); |
1137 | 1172 | }); |
0 commit comments