From d64e54942cdf533a30ebf546e8d2207176fbc35a Mon Sep 17 00:00:00 2001 From: Salakar Date: Tue, 18 Jul 2017 06:05:30 +0100 Subject: [PATCH] [tests][core] start of core/app tests --- tests/src/tests/core/coreTests.js | 68 +++++++++++++++++++++++++++++++ tests/src/tests/core/index.js | 10 +++++ tests/src/tests/index.js | 2 + 3 files changed, 80 insertions(+) create mode 100644 tests/src/tests/core/coreTests.js create mode 100644 tests/src/tests/core/index.js diff --git a/tests/src/tests/core/coreTests.js b/tests/src/tests/core/coreTests.js new file mode 100644 index 00000000..0748f152 --- /dev/null +++ b/tests/src/tests/core/coreTests.js @@ -0,0 +1,68 @@ +import { Platform } from 'react-native'; +import should from 'should'; + +import RNFirebase from './../../../firebase/firebase'; + +const androidTestConfig = { + // 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 iosTestConfig = { + clientId: '305229645282-22imndi01abc2p6esgtu1i1m9mqrd0ib.apps.googleusercontent.com', + androidClientId: androidTestConfig.clientId, + appId: '1:305229645282:ios:7b45748cb1117d2d', + apiKey: 'AIzaSyDnVqNhxU0Biit9nCo4RorAh5ulQQwko3E', + databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com', + storageBucket: 'rnfirebase-b9ad4.appspot.com', + messagingSenderId: '305229645282', + projectId: 'rnfirebase-b9ad4', +}; + +function coreTests({ before, describe, it, firebase }) { + before(() => { + // todo + }); + + describe('Core', () => { + it('it should create js apps for natively initialized apps', () => { + should.equal(RNFirebase.app()._nativeInitialized, true); + return Promise.resolve(); + }); + + it('it should resolve onReady for natively initialized apps', () => { + return RNFirebase.app().onReady(); + }); + + it('it should provide an array of apps', () => { + should.equal(!!RNFirebase.apps.length, true); + should.equal(RNFirebase.apps[0]._name, RNFirebase.DEFAULT_APP_NAME); + should.equal(RNFirebase.apps[0].name, '[DEFAULT]'); + return Promise.resolve(); + }); + + it('it should provide the sdk version', () => { + should.equal(!!RNFirebase.SDK_VERSION.length, true); + return Promise.resolve(); + }); + + it('it should initialize dynamic apps', () => { + return RNFirebase + .initializeApp(Platform.OS === 'ios' ? iosTestConfig : androidTestConfig, 'testsCoreApp') + .onReady() + .then((newApp) => { + newApp.name.should.equal('TESTSCOREAPP'); + newApp.options.apiKey.should.equal((Platform.OS === 'ios' ? iosTestConfig : androidTestConfig).apiKey); + return newApp.delete(); + }); + }); + }); +} + +export default coreTests; diff --git a/tests/src/tests/core/index.js b/tests/src/tests/core/index.js new file mode 100644 index 00000000..d2fcf2d0 --- /dev/null +++ b/tests/src/tests/core/index.js @@ -0,0 +1,10 @@ +import firebase from '../../firebase'; +import TestSuite from '../../../lib/TestSuite'; +import coreTests from './coreTests'; + +const suite = new TestSuite('Firebase Core', 'firebase.X', firebase); + +// bootstrap tests +suite.addTests(coreTests); + +export default suite; diff --git a/tests/src/tests/index.js b/tests/src/tests/index.js index e516306c..85d1a390 100644 --- a/tests/src/tests/index.js +++ b/tests/src/tests/index.js @@ -1,6 +1,7 @@ import { setSuiteStatus, setTestStatus } from '../actions/TestActions'; import analytics from './analytics/index'; import crash from './crash/index'; +import core from './core/index'; import database from './database/index'; import messaging from './messaging/index'; import storage from './storage/index'; @@ -15,6 +16,7 @@ const testSuiteInstances = [ analytics, messaging, crash, + core, storage, config, performance,