[tests][functions] update cloud function to support primitive types of data and return a string value of the type that was sent

This commit is contained in:
Salakar 2018-05-05 18:32:56 +01:00
parent 9fa059bd0b
commit ca068dbbab
1 changed files with 24 additions and 0 deletions

View File

@ -3,6 +3,30 @@ const functions = require('firebase-functions');
const TEST_DATA = require('./test-data');
exports.runTest = functions.https.onCall(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(