Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions packages/app/lib/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,23 @@ const mapOfDeprecationReplacements = {
nanoseconds: NO_REPLACEMENT,
},
},
functions: {
default: {
useEmulator: 'connectFirestoreEmulator()',
httpsCallable: 'httpsCallable()',
httpsCallableFromUrl: 'httpsCallableFromUrl()',
},
statics: {
HttpsErrorCode: 'HttpsErrorCode',
},
},
installations: {
default: {
delete: 'deleteInstallations()',
getId: 'getId()',
getToken: 'getToken()',
},
},
messaging: {
default: {
isAutoInitEnabled: 'isAutoInitEnabled()',
Expand Down Expand Up @@ -437,16 +454,6 @@ const mapOfDeprecationReplacements = {
TaskState: 'TaskState',
},
},
functions: {
default: {
useEmulator: 'connectFirestoreEmulator()',
httpsCallable: 'httpsCallable()',
httpsCallableFromUrl: 'httpsCallableFromUrl()',
},
statics: {
HttpsErrorCode: 'HttpsErrorCode',
},
},
};

const modularDeprecationMessage =
Expand Down
58 changes: 57 additions & 1 deletion packages/installations/__tests__/installations.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { afterAll, beforeAll, describe, expect, it, beforeEach, jest } from '@jest/globals';

import {
firebase,
Expand All @@ -9,6 +9,14 @@ import {
onIdChange,
} from '../lib';

import {
createCheckV9Deprecation,
CheckV9DeprecationFunction,
} from '../../app/lib/common/unitTestUtils';

// @ts-ignore test
import FirebaseModule from '../../app/lib/internal/FirebaseModule';

describe('installations()', function () {
describe('namespace', function () {
beforeAll(async function () {
Expand Down Expand Up @@ -76,4 +84,52 @@ describe('installations()', function () {
});
});
});

describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
let installationsV9Deprecation: CheckV9DeprecationFunction;

beforeEach(function () {
installationsV9Deprecation = createCheckV9Deprecation(['installations']);

// @ts-ignore test
jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => {
return new Proxy(
{},
{
get: () =>
jest.fn().mockResolvedValue({
constants: {},
} as never),
},
);
});
});

it('delete', function () {
const installations = getInstallations();
installationsV9Deprecation(
() => deleteInstallations(installations),
() => installations.delete(),
'delete',
);
});

it('getId', function () {
const installations = getInstallations();
installationsV9Deprecation(
() => getId(installations),
() => installations.getId(),
'getId',
);
});

it('getToken', function () {
const installations = getInstallations();
installationsV9Deprecation(
() => getToken(installations),
() => installations.getToken(),
'getToken',
);
});
});
});
8 changes: 4 additions & 4 deletions packages/installations/lib/modular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { getApp } from '@react-native-firebase/app';

import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/lib/common';
/**
* @typedef {import('..').FirebaseInstallationsTypes.Module} FirebaseInstallation
*/
Expand All @@ -33,15 +33,15 @@ export function getInstallations(app) {
* @returns {Promise<void>}
*/
export function deleteInstallations(installations) {
return installations.delete();
return installations.delete.call(installations, MODULAR_DEPRECATION_ARG);
}

/**
* @param {FirebaseInstallation} installations
* @returns {Promise<string>}
*/
export function getId(installations) {
return installations.getId();
return installations.getId.call(installations, MODULAR_DEPRECATION_ARG);
}

/**
Expand All @@ -50,7 +50,7 @@ export function getId(installations) {
* @returns {Promise<string>}
*/
export function getToken(installations, forceRefresh) {
return installations.getToken(forceRefresh);
return installations.getToken.call(installations, forceRefresh, MODULAR_DEPRECATION_ARG);
}

/**
Expand Down
Loading