Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { createIntl, createIntlCache, type IntlShape } from '@formatjs/intl';
import { createMock } from '@golevelup/ts-jest';
import { convertTimestampToDate } from '@amalia/ext/dates';
import { dayjs } from '@amalia/ext/dayjs';
import { type IntlService } from '@amalia/kernel/intl/module';
import { PeriodFrequencyEnum } from '@amalia/payout-definition/periods/types';
const enIntl: IntlShape<string> = createIntl({ locale: 'en', defaultLocale: 'en', messages: {} }, createIntlCache());
export const intlServiceMock = createMock<IntlService>({
formatMessage: jest.fn((...args: Parameters<IntlService['formatMessage']>) => enIntl.formatMessage(...args)),
formatList: jest.fn((...args: Parameters<IntlService['formatList']>) => enIntl.formatList(...args)),
formatNumber: jest.fn((...args: Parameters<IntlService['formatNumber']>) => enIntl.formatNumber(...args)),
formatPeriodName: jest.fn((...args: Parameters<IntlService['formatPeriodName']>) => {
const currentPeriodDate = convertTimestampToDate(args[0].startDate);
return dayjs
.utc(currentPeriodDate)
.locale(args[1] ?? 'en')
.format(args[0].frequency === PeriodFrequencyEnum.quarter ? '[Q]Q YYYY' : 'MMMM YYYY');
}),
});
export const MockTestUtils = {
publishMessageMock: null as jest.Mock | null,
};
|