From ca068dbbab468cc399897cd9460ca89a3ce40d8c Mon Sep 17 00:00:00 2001 From: Salakar Date: Sat, 5 May 2018 18:32:56 +0100 Subject: [PATCH] [tests][functions] update cloud function to support primitive types of data and return a string value of the type that was sent --- bridge/functions/index.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bridge/functions/index.js b/bridge/functions/index.js index 596798b7..b778216b 100644 --- a/bridge/functions/index.js +++ b/bridge/functions/index.js @@ -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(