From 2d744b162e689bc1794eade0ec581c143b3c7ca9 Mon Sep 17 00:00:00 2001 From: Salakar Date: Mon, 17 Jul 2017 19:44:47 +0100 Subject: [PATCH] [tests] update firebase helper to initialize additional apps --- lib/firebase.js | 9 +++++++++ tests/src/firebase.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/lib/firebase.js b/lib/firebase.js index 7fd50a32..bbddff42 100644 --- a/lib/firebase.js +++ b/lib/firebase.js @@ -50,6 +50,15 @@ class FirebaseCore { } // todo validate required options + // todo required: + /* + appProps.put("apiKey", appOptions.getApiKey()); + appProps.put("applicationId", appOptions.getApplicationId()); + appProps.put("databaseUrl", appOptions.getDatabaseUrl()); + appProps.put("messagingSenderId", appOptions.getGcmSenderId()); + appProps.put("projectId", appOptions.getProjectId()); + appProps.put("storageBucket", appOptions.getStorageBucket()); + */ if (name && !isString(name)) { throw new Error(INTERNALS.STRINGS.ERROR_INIT_STRING_NAME); diff --git a/tests/src/firebase.js b/tests/src/firebase.js index 0d5e4e77..6b6aa604 100644 --- a/tests/src/firebase.js +++ b/tests/src/firebase.js @@ -1,5 +1,6 @@ import firebase from 'firebase'; import RNfirebase from './../firebase/firebase'; +import { Platform } from 'react-native'; import DatabaseContents from './tests/support/DatabaseContents'; @@ -11,13 +12,46 @@ const config = { messagingSenderId: '305229645282', }; +const android = { + // firebase android sdk completely ignores client id + clientId: '305229645282-j8ij0jev9ut24odmlk9i215pas808ugn.apps.googleusercontent.com', + appId: '1:305229645282:android:efe37851d57e1d05', + apiKey: 'AIzaSyDnVqNhxU0Biit9nCo4RorAh5ulQQwko3E', + databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com', + storageBucket: 'rnfirebase-b9ad4.appspot.com', + messagingSenderId: '305229645282', + projectId: 'rnfirebase-b9ad4', +}; + + +const ios = { + clientId: '305229645282-22imndi01abc2p6esgtu1i1m9mqrd0ib.apps.googleusercontent.com', + androidClientId: android.clientId, + appId: '1:305229645282:ios:7b45748cb1117d2d', + apiKey: 'AIzaSyDnVqNhxU0Biit9nCo4RorAh5ulQQwko3E', + databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com', + storageBucket: 'rnfirebase-b9ad4.appspot.com', + messagingSenderId: '305229645282', + projectId: 'rnfirebase-b9ad4', +}; + const instances = { web: firebase.initializeApp(config), native: RNfirebase.app(), + another: RNfirebase.initializeApp(Platform.OS === 'ios' ? ios : android, 'anotherApp'), }; console.log('RNApps -->', RNfirebase.apps); +instances.native.auth().signInAnonymously().then((user) => { + console.log('defaultApp user ->', user.toJSON()); +}); + +instances.another.auth().signInAnonymously().then((user) => { + console.log('anotherApp user ->', user.toJSON()); +}); + + instances.web.database().ref('tests/types').set(DatabaseContents.DEFAULT); instances.web.database().ref('tests/priority').setWithPriority({