mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-06 22:38:47 +08:00
[tests] remove functions project
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
const assert = require('assert');
|
||||
const functions = require('firebase-functions');
|
||||
|
||||
const TEST_DATA = require('./test-data');
|
||||
|
||||
exports.runTestWithRegion = functions
|
||||
.region('europe-west1')
|
||||
.https.onCall(() => 'europe-west1');
|
||||
|
||||
exports.runTest = functions.https.onCall(data => {
|
||||
console.log(Date.now(), data);
|
||||
|
||||
if (typeof data === 'undefined') {
|
||||
return 'undefined';
|
||||
}
|
||||
|
||||
if (typeof data === 'string') {
|
||||
return 'string';
|
||||
}
|
||||
|
||||
if (typeof data === 'number') {
|
||||
return 'number';
|
||||
}
|
||||
|
||||
if (typeof data === 'boolean') {
|
||||
return 'boolean';
|
||||
}
|
||||
|
||||
if (data === null) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
return 'array';
|
||||
}
|
||||
|
||||
const { type, asError, inputData } = data;
|
||||
if (!Object.hasOwnProperty.call(TEST_DATA, type)) {
|
||||
throw new functions.https.HttpsError(
|
||||
'invalid-argument',
|
||||
'Invalid test requested.'
|
||||
);
|
||||
}
|
||||
|
||||
const outputData = TEST_DATA[type];
|
||||
|
||||
try {
|
||||
assert.deepEqual(outputData, inputData);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw new functions.https.HttpsError(
|
||||
'invalid-argument',
|
||||
'Input and Output types did not match.',
|
||||
e.message
|
||||
);
|
||||
}
|
||||
|
||||
// all good
|
||||
if (asError) {
|
||||
throw new functions.https.HttpsError(
|
||||
'cancelled',
|
||||
'Response data was requested to be sent as part of an Error payload, so here we are!',
|
||||
outputData
|
||||
);
|
||||
}
|
||||
|
||||
return outputData;
|
||||
});
|
||||
3886
tests/functions/package-lock.json
generated
3886
tests/functions/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"name": "functions",
|
||||
"description": "Cloud Functions for Firebase",
|
||||
"scripts": {
|
||||
"serve": "firebase serve --only functions",
|
||||
"shell": "firebase functions:shell",
|
||||
"start": "npm run shell",
|
||||
"deploy": "firebase deploy --only functions",
|
||||
"logs": "firebase functions:log"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase-admin": "^6.0.0",
|
||||
"firebase-functions": "^2.0.5"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
module.exports = {
|
||||
number: 1234,
|
||||
string: 'acde',
|
||||
boolean: true,
|
||||
null: null,
|
||||
simpleObject: {
|
||||
number: 1234,
|
||||
string: 'acde',
|
||||
boolean: true,
|
||||
null: null,
|
||||
},
|
||||
simpleArray: [1234, 'acde', true, null],
|
||||
advancedObject: {
|
||||
array: [1234, 'acde', false, null],
|
||||
object: {
|
||||
number: 1234,
|
||||
string: 'acde',
|
||||
boolean: true,
|
||||
null: null,
|
||||
array: [1234, 'acde', true, null],
|
||||
},
|
||||
number: 1234,
|
||||
string: 'acde',
|
||||
boolean: true,
|
||||
null: null,
|
||||
},
|
||||
advancedArray: [
|
||||
1234,
|
||||
'acde',
|
||||
true,
|
||||
null,
|
||||
[1234, 'acde', true, null],
|
||||
{
|
||||
number: 1234,
|
||||
string: 'acde',
|
||||
boolean: true,
|
||||
null: null,
|
||||
array: [1234, 'acde', true, null],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -116,7 +116,7 @@ const iosTestConfig = {
|
||||
|
||||
global.TestHelpers = {
|
||||
functions: {
|
||||
data: require('./../functions/test-data'),
|
||||
data: require('@invertase/tests-firebase-functions').TEST_DATA,
|
||||
},
|
||||
firestore: require('./firestore'),
|
||||
database: require('./database'),
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
"react-native": "0.58.0-rc.1",
|
||||
"should": "^13.2.1",
|
||||
"should-sinon": "0.0.6",
|
||||
"sinon": "^6.2.0"
|
||||
"sinon": "^6.2.0",
|
||||
"@invertase/tests-firebase-functions": "^0.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-transform-runtime": "^7.0.0",
|
||||
|
||||
@@ -773,6 +773,11 @@
|
||||
through2 "^2.0.0"
|
||||
xdg-basedir "^3.0.0"
|
||||
|
||||
"@invertase/tests-firebase-functions@^0.0.1":
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@invertase/tests-firebase-functions/-/tests-firebase-functions-0.0.1.tgz#13286db7243ef2b68385730366fad7e9d7e4916d"
|
||||
integrity sha512-1Ej1mZZFE2b3mHXlwTlsSTPJKdU3XIeX1q/m10zoPt9C07Fl8d05yKOuGoovdJQHREUI9FKSX+JYeRB0FczxsQ==
|
||||
|
||||
"@mrmlnc/readdir-enhanced@^2.2.1":
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
|
||||
|
||||
Reference in New Issue
Block a user