Qualify CJS-only module imports

This commit is contained in:
Fedor Indutny
2025-09-19 13:05:51 -07:00
committed by GitHub
parent 140241b83f
commit 40eaf078cc
401 changed files with 1278 additions and 593 deletions

View File

@@ -2,10 +2,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { noop } from 'lodash';
import lodash from 'lodash';
import { AbortableProcess } from '../../util/AbortableProcess.js';
const { noop } = lodash;
describe('AbortableProcess', () => {
it('resolves the result normally', async () => {
const process = new AbortableProcess(

View File

@@ -9,8 +9,7 @@ import {
CallType,
GroupCallStatus,
} from '../../types/CallDisposition.js';
import { setupI18n } from '../../util/setupI18n.js';
import enMessages from '../../../_locales/en/messages.json';
import i18n from './i18n.js';
import {
getDefaultConversation,
getDefaultGroup,
@@ -19,8 +18,6 @@ import { getPeerIdFromConversation } from '../../util/callDisposition.js';
import { HOUR } from '../../util/durations/index.js';
describe('calling notification helpers', () => {
const i18n = setupI18n('en', enMessages);
describe('getCallingNotificationText', () => {
// Direct call behavior is not tested here.

View File

@@ -2,11 +2,13 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { pick } from 'lodash';
import lodash from 'lodash';
import { getDefaultConversation } from '../../test-helpers/getDefaultConversation.js';
import { filterAndSortConversations } from '../../util/filterAndSortConversations.js';
import type { ConversationType } from '../../state/ducks/conversations.js';
const { pick } = lodash;
type CheckProps = Pick<ConversationType, 'title' | 'activeAt' | 'e164'>;
function check({

View File

@@ -3,8 +3,7 @@
import { assert } from 'chai';
import * as sinon from 'sinon';
import { setupI18n } from '../../util/setupI18n.js';
import enMessages from '../../../_locales/en/messages.json';
import i18n from './i18n.js';
import { getMuteOptions } from '../../util/getMuteOptions.js';
@@ -35,8 +34,6 @@ describe('getMuteOptions', () => {
},
];
const i18n = setupI18n('en', enMessages);
describe('when not muted', () => {
it('returns the 5 default options', () => {
assert.deepStrictEqual(

View File

@@ -3,14 +3,11 @@
import { assert } from 'chai';
import * as sinon from 'sinon';
import { setupI18n } from '../../util/setupI18n.js';
import enMessages from '../../../_locales/en/messages.json';
import i18n from './i18n.js';
import { getMutedUntilText } from '../../util/getMutedUntilText.js';
describe('getMutedUntilText', () => {
const i18n = setupI18n('en', enMessages);
let sandbox: sinon.SinonSandbox;
beforeEach(() => {

View File

@@ -4,11 +4,13 @@
import { assert } from 'chai';
import { Readable } from 'node:stream';
import * as sinon from 'sinon';
import { noop } from 'lodash';
import lodash from 'lodash';
import { once } from 'node:events';
import { getStreamWithTimeout } from '../../util/getStreamWithTimeout.js';
const { noop } = lodash;
describe('getStreamWithTimeout', () => {
let sandbox: sinon.SinonSandbox;
let clock: sinon.SinonFakeTimers;

21
ts/test-node/util/i18n.ts Normal file
View File

@@ -0,0 +1,21 @@
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { setupI18n } from '../../util/setupI18n.js';
const PATH = join(
__dirname,
'..',
'..',
'..',
'_locales',
'en',
'messages.json'
);
export const enMessages = JSON.parse(readFileSync(PATH, 'utf8'));
export default setupI18n('en', enMessages);

View File

@@ -1,7 +1,7 @@
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { mapValues, pick } from 'lodash';
import lodash from 'lodash';
import type { CustomError } from '../../textsecure/Types.js';
@@ -25,6 +25,8 @@ import {
} from '../../services/notifications.js';
import type { MessageModel } from '../../models/messages.js';
const { mapValues, pick } = lodash;
const log = createLogger('messageFailures');
export async function saveErrorsOnMessage(

View File

@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { times } from 'lodash';
import lodash from 'lodash';
import { v4 as uuid } from 'uuid';
import type { LastMessageStatus } from '../../model-types.d.ts';
import { MINUTE, SECOND } from '../../util/durations/index.js';
@@ -15,6 +15,8 @@ import {
TimelineMessageLoadingState,
} from '../../util/timelineUtil.js';
const { times } = lodash;
describe('<Timeline> utilities', () => {
describe('areMessagesInSameGroup', () => {
const defaultNewer: MaybeMessageTimelineItemType = {

View File

@@ -5,8 +5,7 @@ import { assert } from 'chai';
import * as sinon from 'sinon';
import moment from 'moment';
import { HOUR, DAY } from '../../util/durations/index.js';
import { setupI18n } from '../../util/setupI18n.js';
import enMessages from '../../../_locales/en/messages.json';
import i18n from './i18n.js';
import {
formatDate,
@@ -36,8 +35,6 @@ describe('timestamp', () => {
});
}
const i18n = setupI18n('en', enMessages);
describe('formatDate', () => {
useFakeTimers();

View File

@@ -4,7 +4,7 @@
import { assert } from 'chai';
import * as fs from 'node:fs';
import path from 'node:path';
import { ServerPublicParams } from '@signalapp/libsignal-client/zkgroup';
import { ServerPublicParams } from '@signalapp/libsignal-client/zkgroup.js';
describe('zkgroup', () => {
describe('serverPublicParams', () => {