Files
Desktop/ts/test-node/groups/limits_test.ts
2025-08-22 10:20:57 -05:00

52 lines
1.8 KiB
TypeScript

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { updateRemoteConfig } from '../../test-helpers/RemoteConfigStub';
import {
getGroupSizeRecommendedLimit,
getGroupSizeHardLimit,
} from '../../groups/limits';
const RECOMMENDED_SIZE_KEY = 'global.groupsv2.maxGroupSize';
const HARD_LIMIT_KEY = 'global.groupsv2.groupSizeHardLimit';
describe('group limit utilities', () => {
describe('getGroupSizeRecommendedLimit', () => {
it('throws if the value in remote config is not defined', async () => {
await updateRemoteConfig([]);
assert.throws(getGroupSizeRecommendedLimit);
});
it('throws if the value in remote config is not a parseable integer', async () => {
await updateRemoteConfig([
{ name: RECOMMENDED_SIZE_KEY, value: 'uh oh' },
]);
assert.throws(getGroupSizeRecommendedLimit);
});
it('returns the value in remote config, parsed as an integer', async () => {
await updateRemoteConfig([{ name: RECOMMENDED_SIZE_KEY, value: '123' }]);
assert.strictEqual(getGroupSizeRecommendedLimit(), 123);
});
});
describe('getGroupSizeHardLimit', () => {
it('throws if the value in remote config is not defined', async () => {
await updateRemoteConfig([]);
assert.throws(getGroupSizeHardLimit);
});
it('throws if the value in remote config is not a parseable integer', async () => {
await updateRemoteConfig([{ name: HARD_LIMIT_KEY, value: 'uh oh' }]);
assert.throws(getGroupSizeHardLimit);
});
it('returns the value in remote config, parsed as an integer', async () => {
await updateRemoteConfig([{ name: HARD_LIMIT_KEY, value: '123' }]);
assert.strictEqual(getGroupSizeHardLimit(), 123);
});
});
});