Skip to content

Commit e61c567

Browse files
committed
Add .expo folder and settings, implement tests for BigList unique key handling
- Created .expo folder with README and settings.json for project configuration. - Added tests for BigList component to ensure unique key handling and section rendering. - Included scenarios for valid data, empty sections, and mixed content to validate robustness.
1 parent dfa308d commit e61c567

File tree

7 files changed

+753
-711
lines changed

7 files changed

+753
-711
lines changed

.expo/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
> Why do I have a folder named ".expo" in my project?
2+
3+
The ".expo" folder is created when an Expo project is started using "expo start" command.
4+
5+
> What do the files contain?
6+
7+
- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds.
8+
- "packager-info.json": contains port numbers and process PIDs that are used to serve the application to the mobile device/simulator.
9+
- "settings.json": contains the server configuration that is used to serve the application manifest.
10+
11+
> Should I commit the ".expo" folder?
12+
13+
No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine.
14+
15+
Upon project creation, the ".expo" folder is already added to your ".gitignore" file.

.expo/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"hostType": "lan",
3+
"lanType": "ip",
4+
"dev": true,
5+
"minify": false,
6+
"urlRandomness": null,
7+
"https": false
8+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import React from "react";
2+
import { Text } from "react-native";
3+
import { render } from "@testing-library/react-native";
4+
5+
import BigList from "../lib/BigList";
6+
7+
describe("BigList Unique Key Fix", () => {
8+
const mockData = [
9+
{ title: "Item 1", description: "Description 1" },
10+
{ title: "Item 2", description: "Description 2" },
11+
{ title: "Item 3", description: "Description 3" },
12+
];
13+
14+
const mockSections = [
15+
[
16+
{ title: "Section 1 Item 1", description: "Description 1.1" },
17+
{ title: "Section 1 Item 2", description: "Description 1.2" },
18+
],
19+
[
20+
{ title: "Section 2 Item 1", description: "Description 2.1" },
21+
{ title: "Section 2 Item 2", description: "Description 2.2" },
22+
],
23+
];
24+
25+
const renderItem = ({ item }) => (
26+
<Text>{item.title}</Text>
27+
);
28+
29+
it("should handle section and index calculations with valid numbers", () => {
30+
const { getByText } = render(
31+
<BigList
32+
sections={mockSections}
33+
itemHeight={50}
34+
renderItem={renderItem}
35+
containerHeight={200}
36+
/>
37+
);
38+
39+
// Should render without errors even if internal calculations occur
40+
expect(getByText("Section 1 Item 1")).toBeTruthy();
41+
});
42+
43+
it("should render sections without NaN in unique key calculations", () => {
44+
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
45+
46+
render(
47+
<BigList
48+
sections={mockSections}
49+
itemHeight={50}
50+
renderItem={renderItem}
51+
containerHeight={200}
52+
/>
53+
);
54+
55+
// Check that no React key-related errors were logged
56+
const keyErrors = consoleSpy.mock.calls.filter(call =>
57+
call.some(arg =>
58+
typeof arg === 'string' && (
59+
arg.includes('key') ||
60+
arg.includes('unique') ||
61+
arg.includes('NaN')
62+
)
63+
)
64+
);
65+
66+
expect(keyErrors).toHaveLength(0);
67+
consoleSpy.mockRestore();
68+
});
69+
70+
it("should handle empty sections gracefully", () => {
71+
const emptySections = [[], []];
72+
73+
const renderResult = render(
74+
<BigList
75+
sections={emptySections}
76+
itemHeight={50}
77+
renderItem={renderItem}
78+
containerHeight={200}
79+
/>
80+
);
81+
82+
// Should render without throwing errors
83+
expect(renderResult).toBeTruthy();
84+
});
85+
86+
it("should handle mixed empty and non-empty sections", () => {
87+
const mixedSections = [
88+
[{ title: "Item 1", description: "Desc 1" }],
89+
[], // Empty section
90+
[{ title: "Item 2", description: "Desc 2" }],
91+
];
92+
93+
const { getByText } = render(
94+
<BigList
95+
sections={mixedSections}
96+
itemHeight={50}
97+
renderItem={renderItem}
98+
containerHeight={200}
99+
/>
100+
);
101+
102+
expect(getByText("Item 1")).toBeTruthy();
103+
expect(getByText("Item 2")).toBeTruthy();
104+
});
105+
});

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"react": "17.0.1",
1818
"react-dom": "17.0.1",
1919
"react-native": "0.64.3",
20-
"react-native-big-list": "^1.6.1",
20+
"react-native-big-list": "file:..",
2121
"react-native-paper": "^4.9.1",
2222
"react-native-safe-area-context": "3.3.2",
2323
"react-native-web": "0.17.1"

example/yarn.lock

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,7 +2669,7 @@ colors@^1.1.2:
26692669
resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78"
26702670
integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==
26712671

2672-
command-exists@^1.2.8, command-exists@^1.2.9:
2672+
command-exists@^1.2.8:
26732673
version "1.2.9"
26742674
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69"
26752675
integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==
@@ -2818,15 +2818,6 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
28182818
shebang-command "^1.2.0"
28192819
which "^1.2.9"
28202820

2821-
cross-spawn@^7.0.3:
2822-
version "7.0.3"
2823-
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
2824-
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
2825-
dependencies:
2826-
path-key "^3.1.0"
2827-
shebang-command "^2.0.0"
2828-
which "^2.0.1"
2829-
28302821
css-in-js-utils@^2.0.0:
28312822
version "2.0.1"
28322823
resolved "https://registry.yarnpkg.com/css-in-js-utils/-/css-in-js-utils-2.0.1.tgz#3b472b398787291b47cfe3e44fecfdd9e914ba99"
@@ -5005,11 +4996,6 @@ path-key@^2.0.0, path-key@^2.0.1:
50054996
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
50064997
integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
50074998

5008-
path-key@^3.1.0:
5009-
version "3.1.1"
5010-
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
5011-
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
5012-
50134999
path-parse@^1.0.6:
50145000
version "1.0.7"
50155001
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
@@ -5139,6 +5125,15 @@ prop-types@^15.6.0, prop-types@^15.7.2:
51395125
object-assign "^4.1.1"
51405126
react-is "^16.8.1"
51415127

5128+
prop-types@^15.8.1:
5129+
version "15.8.1"
5130+
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
5131+
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
5132+
dependencies:
5133+
loose-envify "^1.4.0"
5134+
object-assign "^4.1.1"
5135+
react-is "^16.13.1"
5136+
51425137
pump@^3.0.0:
51435138
version "3.0.0"
51445139
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
@@ -5187,7 +5182,7 @@ [email protected]:
51875182
object-assign "^4.1.1"
51885183
scheduler "^0.20.1"
51895184

5190-
react-is@^16.7.0, react-is@^16.8.1:
5185+
react-is@^16.13.1, react-is@^16.7.0, react-is@^16.8.1:
51915186
version "16.13.1"
51925187
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
51935188
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
@@ -5197,13 +5192,10 @@ react-is@^17.0.1:
51975192
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
51985193
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
51995194

5200-
react-native-big-list@^1.4.3:
5201-
version "1.4.3"
5202-
resolved "https://registry.yarnpkg.com/react-native-big-list/-/react-native-big-list-1.4.3.tgz#b5b8980e119183dd6337c0afbcea957eec9bc9ee"
5203-
integrity sha512-gP6CWSquEuLcKJmkmP/YbWhU9nyetpJ9jXYJHRor+iuRUSoA+21gK71GC0eGMPEg0Scl3+lfPhCH9JfECwYAXw==
5195+
"react-native-big-list@file:..":
5196+
version "1.6.3"
52045197
dependencies:
5205-
prop-types "^15.7.2"
5206-
yarpm "^1.1.1"
5198+
prop-types "^15.8.1"
52075199

52085200
react-native-codegen@^0.0.6:
52095201
version "0.0.6"
@@ -5640,23 +5632,11 @@ shebang-command@^1.2.0:
56405632
dependencies:
56415633
shebang-regex "^1.0.0"
56425634

5643-
shebang-command@^2.0.0:
5644-
version "2.0.0"
5645-
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
5646-
integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==
5647-
dependencies:
5648-
shebang-regex "^3.0.0"
5649-
56505635
shebang-regex@^1.0.0:
56515636
version "1.0.0"
56525637
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
56535638
integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
56545639

5655-
shebang-regex@^3.0.0:
5656-
version "3.0.0"
5657-
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
5658-
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
5659-
56605640
56615641
version "1.6.1"
56625642
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767"
@@ -6203,13 +6183,6 @@ which@^1.2.9:
62036183
dependencies:
62046184
isexe "^2.0.0"
62056185

6206-
which@^2.0.1:
6207-
version "2.0.2"
6208-
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
6209-
integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==
6210-
dependencies:
6211-
isexe "^2.0.0"
6212-
62136186
wrap-ansi@^6.2.0:
62146187
version "6.2.0"
62156188
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
@@ -6339,14 +6312,6 @@ yargs@^15.1.0, yargs@^15.3.1:
63396312
y18n "^4.0.0"
63406313
yargs-parser "^18.1.2"
63416314

6342-
yarpm@^1.1.1:
6343-
version "1.1.1"
6344-
resolved "https://registry.yarnpkg.com/yarpm/-/yarpm-1.1.1.tgz#23e25e512b409d941524a9674718f1871e5fb52a"
6345-
integrity sha512-A3gVdtyld+gYcVmKScvJqS2oT/i9xdsb/SqDsY9c0+BeYdYBUJrRfr4pD7UP+5uXEneJ0BL0rC/6rd1fnlYEcg==
6346-
dependencies:
6347-
command-exists "^1.2.9"
6348-
cross-spawn "^7.0.3"
6349-
63506315
yocto-queue@^0.1.0:
63516316
version "0.1.0"
63526317
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"

0 commit comments

Comments
 (0)