[tests] remove functions project

This commit is contained in:
Salakar
2019-01-08 20:59:02 +00:00
parent 094affc2c8
commit 4be1ae70de
7 changed files with 8 additions and 4013 deletions

View File

@@ -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;
});

File diff suppressed because it is too large Load Diff

View File

@@ -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
}

View File

@@ -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],
},
],
};

View File

@@ -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'),

View File

@@ -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",

View File

@@ -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"