Skip to content

Commit 1466189

Browse files
committed
style: prettier + ts-ignore fix for renderText.tsx build
- src/components/Message/MessageItemView/utils/renderText.tsx: restore the directive for the untyped `react-native-markdown-package` import, but use `@ts-ignore` instead of `@ts-expect-error`. The base tsconfig (with noImplicitAny: true) needs the suppression for bob's `yarn build` to succeed; the test tsconfig (with noImplicitAny: false) doesn't report the import as an error, so `@ts-expect-error` would read as "unused". `@ts-ignore` is tolerant of both. - prettier auto-formatting across a handful of recently edited test files.
1 parent 95e137f commit 1466189

10 files changed

Lines changed: 38 additions & 43 deletions

File tree

package/src/components/Channel/__tests__/Channel.test.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,15 @@ describe('Channel', () => {
219219
await waitFor(() => expect(hasThread).toHaveBeenCalledWith(threadMessage.id));
220220
});
221221

222-
const queryChannelWithNewMessages = (
223-
newMessages: ReturnType<typeof generateMessage>[],
224-
) =>
222+
const queryChannelWithNewMessages = (newMessages: ReturnType<typeof generateMessage>[]) =>
225223
// generate new channel mock from existing channel with new messages added
226224
getOrCreateChannelApi(
227225
generateChannelResponse({
228226
channel: {
229227
config: channel.getConfig(),
230228
id: channel.id,
231229
type: channel.type,
232-
} as unknown as NonNullable<
233-
Parameters<typeof generateChannelResponse>[0]
234-
>['channel'],
230+
} as unknown as NonNullable<Parameters<typeof generateChannelResponse>[0]>['channel'],
235231
messages: newMessages,
236232
}),
237233
);
@@ -387,9 +383,7 @@ describe('Channel initial load useEffect', () => {
387383
const renderComponent = (props: RenderComponentProps = {}) =>
388384
render(
389385
<Chat client={chatClient}>
390-
<Channel {...(props as React.ComponentProps<typeof Channel>)}>
391-
{props.children}
392-
</Channel>
386+
<Channel {...(props as React.ComponentProps<typeof Channel>)}>{props.children}</Channel>
393387
</Chat>,
394388
);
395389

package/src/components/Channel/__tests__/useMessageListPagination.test.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,7 @@ describe('useMessageListPagination', () => {
403403
};
404404
initialMessages: MessageResponse[];
405405
name: string;
406-
setupLoadMessageIntoState:
407-
| ((channel: ChannelType) => jest.Mock)
408-
| null;
406+
setupLoadMessageIntoState: ((channel: ChannelType) => jest.Mock) | null;
409407
};
410408

411409
// Test cases with different scenarios
@@ -448,9 +446,8 @@ describe('useMessageListPagination', () => {
448446
channel.state.messages = newMessages as unknown as typeof channel.state.messages;
449447
(channel.state.messagePagination as { hasPrev: boolean }).hasPrev = true;
450448
});
451-
(
452-
channel.state as unknown as { loadMessageIntoState: jest.Mock }
453-
).loadMessageIntoState = loadMessageIntoState;
449+
(channel.state as unknown as { loadMessageIntoState: jest.Mock }).loadMessageIntoState =
450+
loadMessageIntoState;
454451
return loadMessageIntoState;
455452
},
456453
},
@@ -492,9 +489,8 @@ describe('useMessageListPagination', () => {
492489
channel.state.messages = newMessages as unknown as typeof channel.state.messages;
493490
(channel.state.messagePagination as { hasPrev: boolean }).hasPrev = true;
494491
});
495-
(
496-
channel.state as unknown as { loadMessageIntoState: jest.Mock }
497-
).loadMessageIntoState = loadMessageIntoState;
492+
(channel.state as unknown as { loadMessageIntoState: jest.Mock }).loadMessageIntoState =
493+
loadMessageIntoState;
498494
return loadMessageIntoState;
499495
},
500496
},
@@ -582,9 +578,9 @@ describe('useMessageListPagination', () => {
582578
const user = generateUser();
583579

584580
it.each`
585-
scenario | last_read | expectedQueryCalls | expectedJumpToMessageFinishedCalls | expectedSetChannelUnreadStateCalls | expectedSetTargetedMessageCalls | expectedTargetedMessageId
581+
scenario | last_read | expectedQueryCalls | expectedJumpToMessageFinishedCalls | expectedSetChannelUnreadStateCalls | expectedSetTargetedMessageCalls | expectedTargetedMessageId
586582
${'when last_read matches a message'} | ${new Date(messages[10].created_at as unknown as Date)} | ${0} | ${1} | ${1} | ${1} | ${'10'}
587-
${'when last_read does not match any message'} | ${new Date('2021-09-02T00:00:00.000Z')} | ${1} | ${0} | ${0} | ${0} | ${undefined}
583+
${'when last_read does not match any message'} | ${new Date('2021-09-02T00:00:00.000Z')} | ${1} | ${0} | ${0} | ${0} | ${undefined}
588584
`(
589585
'$scenario',
590586
async ({

package/src/components/ChannelList/__tests__/ChannelList.test.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,7 @@ describe('ChannelList', () => {
227227
<WithComponents overrides={{ ChannelPreview: ChannelPreviewComponent }}>
228228
<ChannelList
229229
{...props}
230-
filters={
231-
staleFilter as unknown as React.ComponentProps<typeof ChannelList>['filters']
232-
}
230+
filters={staleFilter as unknown as React.ComponentProps<typeof ChannelList>['filters']}
233231
/>
234232
</WithComponents>
235233
</Chat>,
@@ -252,9 +250,7 @@ describe('ChannelList', () => {
252250
<WithComponents overrides={{ ChannelPreview: ChannelPreviewComponent }}>
253251
<ChannelList
254252
{...props}
255-
filters={
256-
freshFilter as unknown as React.ComponentProps<typeof ChannelList>['filters']
257-
}
253+
filters={freshFilter as unknown as React.ComponentProps<typeof ChannelList>['filters']}
258254
/>
259255
</WithComponents>
260256
</Chat>,

package/src/components/ChannelPreview/__tests__/ChannelPreviewView.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ describe('ChannelPreviewView', () => {
6666
render(
6767
getComponent({
6868
onSelect,
69-
...({ watchers: {} } as unknown as Partial<React.ComponentProps<typeof ChannelPreviewView>>),
69+
...({ watchers: {} } as unknown as Partial<
70+
React.ComponentProps<typeof ChannelPreviewView>
71+
>),
7072
}),
7173
);
7274

package/src/components/Chat/__tests__/Chat.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ describe('TranslationContext', () => {
163163
const { t, tDateTimeParser } = await i18nInstance.getTranslators();
164164

165165
i18nInstance.t = (() => 't') as unknown as typeof i18nInstance.t;
166-
i18nInstance.tDateTimeParser = (() => 'tDateTimeParser') as unknown as typeof i18nInstance.tDateTimeParser;
166+
i18nInstance.tDateTimeParser = (() =>
167+
'tDateTimeParser') as unknown as typeof i18nInstance.tDateTimeParser;
167168

168169
render(
169170
<Chat client={chatClient} i18nInstance={i18nInstance}>
@@ -188,7 +189,8 @@ describe('TranslationContext', () => {
188189
const i18nInstance = new Streami18n();
189190

190191
i18nInstance.t = (() => 't') as unknown as typeof i18nInstance.t;
191-
i18nInstance.tDateTimeParser = (() => 'tDateTimeParser') as unknown as typeof i18nInstance.tDateTimeParser;
192+
i18nInstance.tDateTimeParser = (() =>
193+
'tDateTimeParser') as unknown as typeof i18nInstance.tDateTimeParser;
192194

193195
const { rerender } = render(
194196
<Chat client={chatClient} i18nInstance={i18nInstance}>

package/src/components/Message/MessageItemView/__tests__/MessageContent.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,7 @@ describe('MessageContent', () => {
264264
}}
265265
>
266266
<Channel channel={channel}>
267-
<Message
268-
groupStyles={['bottom']}
269-
message={toLocalMessage(rightAlignedMessage)}
270-
/>
267+
<Message groupStyles={['bottom']} message={toLocalMessage(rightAlignedMessage)} />
271268
</Channel>
272269
</WithComponents>
273270
</Chat>

package/src/components/Message/MessageItemView/utils/renderText.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from 'react-native';
1212

1313
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
14+
// @ts-ignore -- no type definitions available for `react-native-markdown-package`
1415
import Markdown from 'react-native-markdown-package';
1516
import Animated, { clamp, scrollTo, useAnimatedRef, useSharedValue } from 'react-native-reanimated';
1617

package/src/components/MessageList/__tests__/ScrollToBottomButton.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ describe('ScrollToBottomButton', () => {
6969
const translators = await i18nInstance.getTranslators();
7070
const { getByTestId, getByText } = render(
7171
<ThemeProvider>
72-
<TranslationProvider
73-
value={{ ...translators, t } as unknown as TranslationContextValue}
74-
>
72+
<TranslationProvider value={{ ...translators, t } as unknown as TranslationContextValue}>
7573
<ScrollToBottomButton
7674
{...({ t } as unknown as React.ComponentProps<typeof ScrollToBottomButton>)}
7775
onPress={() => null}

package/src/components/Thread/__tests__/Thread.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ describe('Thread', () => {
156156
}
157157
>
158158
<ImageGalleryProvider
159-
value={
160-
{} as unknown as React.ComponentProps<typeof ImageGalleryProvider>['value']
161-
}
159+
value={{} as unknown as React.ComponentProps<typeof ImageGalleryProvider>['value']}
162160
>
163161
<Channel
164162
channel={channel}

package/src/utils/__tests__/Streami18n.test.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,17 @@ describe('Streami18n instance - with built-in language', () => {
102102
dayjsLocaleConfigForLanguage: customDayjsLocaleConfig,
103103
language: 'nl',
104104
};
105-
const streami18n = new Streami18n(streami18nOptions as unknown as ConstructorParameters<typeof Streami18n>[0]);
105+
const streami18n = new Streami18n(
106+
streami18nOptions as unknown as ConstructorParameters<typeof Streami18n>[0],
107+
);
106108

107109
it('should provide dayjs with given custom locale config', async () => {
108110
const { tDateTimeParser } = await streami18n.getTranslators();
109111
expect(tDateTimeParser() instanceof Dayjs).toBe(true);
110-
const localeConfig = (tDateTimeParser() as Dayjs.Dayjs).localeData() as unknown as Record<string, unknown>;
112+
const localeConfig = (tDateTimeParser() as Dayjs.Dayjs).localeData() as unknown as Record<
113+
string,
114+
unknown
115+
>;
111116
for (const key in streami18nOptions.dayjsLocaleConfigForLanguage) {
112117
if (typeof localeConfig[key] === 'function') {
113118
expect((localeConfig[key] as () => unknown)()).toStrictEqual(
@@ -268,15 +273,21 @@ describe('Streami18n timezone', () => {
268273
it('allows to override the default timestampFormatter', async () => {
269274
const i18n = new Streami18n({
270275
formatters: { timestampFormatter: () => () => 'custom' },
271-
translationsForLanguage: { abc: '{{ value | timestampFormatter }}' } as unknown as Record<string, string>,
276+
translationsForLanguage: { abc: '{{ value | timestampFormatter }}' } as unknown as Record<
277+
string,
278+
string
279+
>,
272280
});
273281
await (i18n as unknown as { init: () => Promise<void> }).init();
274282
expect(i18n.t('abc')).toBe('custom');
275283
});
276284
it('allows to add new custom formatter', async () => {
277285
const i18n = new Streami18n({
278286
formatters: { customFormatter: () => () => 'custom' },
279-
translationsForLanguage: { abc: '{{ value | customFormatter }}' } as unknown as Record<string, string>,
287+
translationsForLanguage: { abc: '{{ value | customFormatter }}' } as unknown as Record<
288+
string,
289+
string
290+
>,
280291
});
281292
await (i18n as unknown as { init: () => Promise<void> }).init();
282293
expect(i18n.t('abc')).toBe('custom');

0 commit comments

Comments
 (0)