Skip to content

Commit 8fd61cb

Browse files
committed
fixing eslint
1 parent be822cf commit 8fd61cb

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

tests/unit/ImageSVGCachePolicyTest.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ jest.mock('expo-image', () => ({
2020
},
2121
}));
2222

23-
jest.mock('@libs/getImageRecyclingKey', () => ({
24-
__esModule: true,
25-
default: jest.fn((source: unknown) => {
23+
jest.mock('@libs/getImageRecyclingKey', () =>
24+
jest.fn((source: unknown) => {
2625
if (typeof source === 'number') {
2726
return String(source);
2827
}
@@ -31,10 +30,14 @@ jest.mock('@libs/getImageRecyclingKey', () => ({
3130
}
3231
return undefined;
3332
}),
34-
}));
33+
);
3534

3635
const MOCK_STATIC_SOURCE = 42;
3736

37+
function getFirstCallProps(): Record<string, unknown> {
38+
return mockImageComponent.mock.calls.at(0)?.at(0) as Record<string, unknown>;
39+
}
40+
3841
describe('ImageSVG cache policy', () => {
3942
beforeEach(() => {
4043
jest.clearAllMocks();
@@ -45,14 +48,14 @@ describe('ImageSVG cache policy', () => {
4548
render(<ImageSVGiOS src={MOCK_STATIC_SOURCE} />);
4649

4750
expect(mockImageComponent).toHaveBeenCalled();
48-
const props = mockImageComponent.mock.calls[0][0] as Record<string, unknown>;
51+
const props = getFirstCallProps();
4952
expect(props.cachePolicy).toBe('memory-disk');
5053
});
5154

5255
it('should set recyclingKey for static image sources', () => {
5356
render(<ImageSVGiOS src={MOCK_STATIC_SOURCE} />);
5457

55-
const props = mockImageComponent.mock.calls[0][0] as Record<string, unknown>;
58+
const props = getFirstCallProps();
5659
expect(props.recyclingKey).toBe(String(MOCK_STATIC_SOURCE));
5760
});
5861

@@ -77,14 +80,14 @@ describe('ImageSVG cache policy', () => {
7780
render(<ImageSVGAndroid src={MOCK_STATIC_SOURCE} />);
7881

7982
expect(mockImageComponent).toHaveBeenCalled();
80-
const props = mockImageComponent.mock.calls[0][0] as Record<string, unknown>;
83+
const props = getFirstCallProps();
8184
expect(props.cachePolicy).toBe('memory');
8285
});
8386

8487
it('should set recyclingKey for static image sources', () => {
8588
render(<ImageSVGAndroid src={MOCK_STATIC_SOURCE} />);
8689

87-
const props = mockImageComponent.mock.calls[0][0] as Record<string, unknown>;
90+
const props = getFirstCallProps();
8891
expect(props.recyclingKey).toBe(String(MOCK_STATIC_SOURCE));
8992
});
9093

0 commit comments

Comments
 (0)