From 33c7f5db0c9cd58468e0bdb76daf6dde20214942 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 6 Feb 2025 11:08:05 +0000 Subject: [PATCH] test: setCustomSignals e2e tests --- packages/remote-config/e2e/config.e2e.js | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/remote-config/e2e/config.e2e.js b/packages/remote-config/e2e/config.e2e.js index 6df8eabaea..5ec9695135 100644 --- a/packages/remote-config/e2e/config.e2e.js +++ b/packages/remote-config/e2e/config.e2e.js @@ -954,5 +954,43 @@ describe('remoteConfig()', function () { // console.log('checking listener functionality across javascript layer reload'); }); }); + + describe('setCustomSignals()', function () { + it('should resolve with valid signal value; `string`, `number` or `null`', async function () { + const { setCustomSignals, getRemoteConfig } = remoteConfigModular; + const remoteConfig = getRemoteConfig(firebase.app()); + // native SDKs just ignore invalid key/values (e.g. too long) and just log warning + const signals = { + string: 'string', + number: 123, + double: 123.456, + null: null, + }; + + const result = await setCustomSignals(remoteConfig, signals); + should(result).equal(null); + }); + + it('should reject with invalid signal value', async function () { + const { setCustomSignals, getRemoteConfig } = remoteConfigModular; + const remoteConfig = getRemoteConfig(firebase.app()); + + const invalidSignals = [ + { signal1: true }, + { signal1: [1, 2, 3] }, + { signal1: { key: 'value' } }, + { signal1: false }, + ]; + + for (const signals of invalidSignals) { + await should(setCustomSignals(remoteConfig, signals)) + .be.rejectedWith(Error) + .and.have.property('message') + .that.includes( + 'firebase.remoteConfig().setCustomSignals(): Invalid type for custom signal', + ); + } + }); + }); }); });