|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2021 Google LLC |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +import { getModularInstance } from '@firebase/util'; |
| 19 | +import { expect } from 'chai'; |
| 20 | +import { getPerformance } from '@firebase/performance-exp'; |
| 21 | +import firebase from '@firebase/app-compat'; |
| 22 | +import '@firebase/performance-compat'; |
| 23 | + |
| 24 | +import { TEST_PROJECT_CONFIG } from './util'; |
| 25 | + |
| 26 | +firebase.initializeApp(TEST_PROJECT_CONFIG); |
| 27 | + |
| 28 | +const compatPerf = firebase.performance(); |
| 29 | +const modularPerf = getPerformance(); |
| 30 | + |
| 31 | +describe('Performance compat interop', () => { |
| 32 | + it('Performance compat instance references modular Performance instance', () => { |
| 33 | + expect(getModularInstance(compatPerf)).to.equal(modularPerf); |
| 34 | + }); |
| 35 | + |
| 36 | + it('Performance compat and modular Performance instance share the same configuration', () => { |
| 37 | + expect(compatPerf.dataCollectionEnabled).to.equal(true); |
| 38 | + expect(compatPerf.instrumentationEnabled).to.equal(true); |
| 39 | + expect(modularPerf.dataCollectionEnabled).to.equal(true); |
| 40 | + expect(modularPerf.instrumentationEnabled).to.equal(true); |
| 41 | + |
| 42 | + // change settings on the compat instance |
| 43 | + compatPerf.dataCollectionEnabled = false; |
| 44 | + compatPerf.instrumentationEnabled = false; |
| 45 | + |
| 46 | + expect(compatPerf.dataCollectionEnabled).to.equal(false); |
| 47 | + expect(compatPerf.instrumentationEnabled).to.equal(false); |
| 48 | + expect(modularPerf.dataCollectionEnabled).to.equal(false); |
| 49 | + expect(modularPerf.instrumentationEnabled).to.equal(false); |
| 50 | + |
| 51 | + // change settings on the modular instance |
| 52 | + modularPerf.dataCollectionEnabled = true; |
| 53 | + modularPerf.instrumentationEnabled = true; |
| 54 | + |
| 55 | + expect(compatPerf.dataCollectionEnabled).to.equal(true); |
| 56 | + expect(compatPerf.instrumentationEnabled).to.equal(true); |
| 57 | + expect(modularPerf.dataCollectionEnabled).to.equal(true); |
| 58 | + expect(modularPerf.instrumentationEnabled).to.equal(true); |
| 59 | + }); |
| 60 | +}); |
0 commit comments