Use esbuild

This commit is contained in:
Fedor Indutny 2022-02-11 13:38:52 -08:00 committed by GitHub
parent 3c1ccce9bd
commit 0174687542
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 528 additions and 906 deletions

View file

@ -1,66 +1,56 @@
// Copyright 2021 Signal Messenger, LLC
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import * as sinon from 'sinon';
import * as remoteConfig from '../../RemoteConfig';
import { updateRemoteConfig } from '../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', () => {
let sinonSandbox: sinon.SinonSandbox;
let getRecommendedLimitStub: sinon.SinonStub;
let getHardLimitStub: sinon.SinonStub;
beforeEach(() => {
sinonSandbox = sinon.createSandbox();
const getValueStub = sinonSandbox.stub(remoteConfig, 'getValue');
getRecommendedLimitStub = getValueStub.withArgs(
'global.groupsv2.maxGroupSize'
);
getHardLimitStub = getValueStub.withArgs(
'global.groupsv2.groupSizeHardLimit'
);
});
afterEach(() => {
sinonSandbox.restore();
});
describe('getGroupSizeRecommendedLimit', () => {
it('throws if the value in remote config is not defined', () => {
getRecommendedLimitStub.returns(undefined);
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', () => {
getRecommendedLimitStub.returns('uh oh');
it('throws if the value in remote config is not a parseable integer', async () => {
await updateRemoteConfig([
{ name: RECOMMENDED_SIZE_KEY, value: 'uh oh', enabled: true },
]);
assert.throws(getGroupSizeRecommendedLimit);
});
it('returns the value in remote config, parsed as an integer', () => {
getRecommendedLimitStub.returns('123');
it('returns the value in remote config, parsed as an integer', async () => {
await updateRemoteConfig([
{ name: RECOMMENDED_SIZE_KEY, value: '123', enabled: true },
]);
assert.strictEqual(getGroupSizeRecommendedLimit(), 123);
});
});
describe('getGroupSizeHardLimit', () => {
it('throws if the value in remote config is not defined', () => {
getHardLimitStub.returns(undefined);
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', () => {
getHardLimitStub.returns('uh oh');
it('throws if the value in remote config is not a parseable integer', async () => {
await updateRemoteConfig([
{ name: HARD_LIMIT_KEY, value: 'uh oh', enabled: true },
]);
assert.throws(getGroupSizeHardLimit);
});
it('returns the value in remote config, parsed as an integer', () => {
getHardLimitStub.returns('123');
it('returns the value in remote config, parsed as an integer', async () => {
await updateRemoteConfig([
{ name: HARD_LIMIT_KEY, value: '123', enabled: true },
]);
assert.strictEqual(getGroupSizeHardLimit(), 123);
});
});