Skip to content

Commit

Permalink
test: setCustomSignals e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Feb 6, 2025
1 parent dc6f99e commit 33c7f5d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/remote-config/e2e/config.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
}
});
});
});
});

0 comments on commit 33c7f5d

Please sign in to comment.