[firestore][tests] Get first collection tests working on Android

This commit is contained in:
Chris Bianca
2017-09-27 15:41:25 +01:00
parent 52b70d58e3
commit bf35c349ae
15 changed files with 206 additions and 38 deletions

View File

@@ -71,7 +71,7 @@ android {
}
}
project.ext.firebaseVersion = '11.2.0'
project.ext.firebaseVersion = '11.3.0'
dependencies {
// compile(project(':react-native-firebase')) {
@@ -82,7 +82,6 @@ dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.google.android.gms:play-services-base:$firebaseVersion"
compile "com.google.firebase:firebase-ads:$firebaseVersion"
compile "com.google.firebase:firebase-ads:$firebaseVersion"
compile "com.google.firebase:firebase-auth:$firebaseVersion"
compile "com.google.firebase:firebase-config:$firebaseVersion"
compile "com.google.firebase:firebase-core:$firebaseVersion"
@@ -91,6 +90,7 @@ dependencies {
compile "com.google.firebase:firebase-messaging:$firebaseVersion"
compile "com.google.firebase:firebase-perf:$firebaseVersion"
compile "com.google.firebase:firebase-storage:$firebaseVersion"
compile "com.google.firebase:firebase-firestore:$firebaseVersion"
compile "com.android.support:appcompat-v7:26.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}

View File

@@ -1,27 +1,30 @@
{
"project_info": {
"project_number": "305229645282",
"firebase_url": "https://rnfirebase-b9ad4.firebaseio.com",
"project_id": "rnfirebase-b9ad4",
"storage_bucket": "rnfirebase-b9ad4.appspot.com"
"project_number": "17067372085",
"firebase_url": "https://rnfirebase-5579a.firebaseio.com",
"project_id": "rnfirebase",
"storage_bucket": "rnfirebase.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:305229645282:android:efe37851d57e1d05",
"mobilesdk_app_id": "1:17067372085:android:efe37851d57e1d05",
"android_client_info": {
"package_name": "com.reactnativefirebasedemo"
}
},
"oauth_client": [
{
"client_id": "305229645282-j8ij0jev9ut24odmlk9i215pas808ugn.apps.googleusercontent.com",
"client_id": "17067372085-n572o9802h9jbv9oo60h53117pk9333k.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCzbBYFyX8d6VdSu7T4s10IWYbPc-dguwM"
"current_key": "AIzaSyB-z0ytgXRRiClvslJl0tp-KbhDub9o6AM"
},
{
"current_key": "AIzaSyAJw8mR1fPcEYC9ouZbkCStJufcCQrhmjQ"
}
],
"services": {

View File

@@ -10,6 +10,7 @@ import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.config.RNFirebaseRemoteConfigPackage;
import io.invertase.firebase.crash.RNFirebaseCrashPackage;
import io.invertase.firebase.database.RNFirebaseDatabasePackage;
import io.invertase.firebase.firestore.RNFirebaseFirestorePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.perf.RNFirebasePerformancePackage;
import io.invertase.firebase.storage.RNFirebaseStoragePackage;
@@ -42,6 +43,7 @@ public class MainApplication extends Application implements ReactApplication {
new RNFirebaseRemoteConfigPackage(),
new RNFirebaseCrashPackage(),
new RNFirebaseDatabasePackage(),
new RNFirebaseFirestorePackage(),
new RNFirebaseMessagingPackage(),
new RNFirebasePerformancePackage(),
new RNFirebaseStoragePackage()

View File

@@ -6,8 +6,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.google.firebase:firebase-plugins:1.1.0'
classpath 'com.google.gms:google-services:3.1.1'
classpath 'com.google.firebase:firebase-plugins:1.1.1'
}
}
@@ -18,6 +18,7 @@ allprojects {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
mavenLocal()
google()
}
}

View File

@@ -0,0 +1,30 @@
// import docSnapTests from './docSnapTests';
// import querySnapTests from './querySnapTests';
// import onSnapshotTests from './onSnapshotTests';
// import bugTests from './bugTests';
import whereTests from './whereTests';
const testGroups = [
// onSnapshotTests,
// querySnapTests,
// docSnapTests,
// bugTests,
whereTests,
];
function registerTestSuite(testSuite) {
testSuite.beforeEach(async function () {
// todo reset test data
});
testSuite.afterEach(async function () {
// todo reset test data
});
testGroups.forEach((testGroup) => {
testGroup(testSuite);
});
}
module.exports = registerTestSuite;

View File

@@ -0,0 +1,86 @@
import should from 'should';
/**
Test document structure from fb console:
baz: true
daz: 123
foo: "bar"
gaz: 12.1234567
naz: null
*/
function whereTests({ describe, it, context, firebase }) {
describe('CollectionReference.where()', () => {
context('correctly handles', () => {
it('== boolean values', () => {
return firebase.native.firestore()
.collection('tests')
.where('baz', '==', true)
.get()
.then((querySnapshot) => {
should.equal(querySnapshot.size, 1);
querySnapshot.forEach((documentSnapshot) => {
should.equal(documentSnapshot.data().baz, true);
});
});
});
it('== string values', () => {
return firebase.native.firestore()
.collection('tests')
.where('foo', '==', 'bar')
.get()
.then((querySnapshot) => {
should.equal(querySnapshot.size, 1);
querySnapshot.forEach((documentSnapshot) => {
should.equal(documentSnapshot.data().foo, 'bar');
});
});
});
it('== null values', () => {
return firebase.native.firestore()
.collection('tests')
.where('naz', '==', null)
.get()
.then((querySnapshot) => {
should.equal(querySnapshot.size, 1);
querySnapshot.forEach((documentSnapshot) => {
should.equal(documentSnapshot.data().naz, null);
});
});
});
it('>= number values', () => {
return firebase.native.firestore()
.collection('tests')
.where('daz', '>=', 123)
.get()
.then((querySnapshot) => {
should.equal(querySnapshot.size, 1);
querySnapshot.forEach((documentSnapshot) => {
should.equal(documentSnapshot.data().daz, 123);
});
});
});
it('<= float values', () => {
return firebase.native.firestore()
.collection('tests')
.where('gaz', '<=', 12.1234666)
.get()
.then((querySnapshot) => {
should.equal(querySnapshot.size, 1);
querySnapshot.forEach((documentSnapshot) => {
should.equal(documentSnapshot.data().gaz, 12.1234567);
});
});
});
});
});
}
export default whereTests;

View File

@@ -0,0 +1,22 @@
// import whereTests from './whereTests';
const testGroups = [
// whereTests,
];
function registerTestSuite(testSuite) {
testSuite.beforeEach(async function () {
// todo reset test data
});
testSuite.afterEach(async function () {
// todo reset test data
});
testGroups.forEach((testGroup) => {
testGroup(testSuite);
});
}
module.exports = registerTestSuite;

View File

@@ -0,0 +1,19 @@
import firebase from '../../firebase';
import TestSuite from '../../../lib/TestSuite';
/*
Test suite files
*/
import collectionTestGroups from './collection/index';
import documentTestGroups from './document/index';
const suite = new TestSuite('Firestore', 'firebase.firestore()', firebase);
/*
Register tests with test suite
*/
suite.addTests(documentTestGroups);
suite.addTests(collectionTestGroups);
export default suite;

View File

@@ -1,26 +1,28 @@
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';
import auth from './auth/index';
import config from './config/index';
import performance from './perf/index';
import admob from './admob/index';
import analytics from './analytics';
import crash from './crash';
import core from './core';
import database from './database';
import messaging from './messaging';
import storage from './storage';
import auth from './auth';
import config from './config';
import performance from './perf';
import admob from './admob';
import firestore from './firestore';
const testSuiteInstances = [
database,
auth,
analytics,
messaging,
crash,
core,
storage,
config,
performance,
admob,
analytics,
auth,
config,
core,
crash,
database,
firestore,
messaging,
performance,
storage,
];
/*