Skip to content

Commit fdcfcc6

Browse files
committed
feat:添加测试组件jest
1 parent bf18e1b commit fdcfcc6

File tree

71 files changed

+7845
-4271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+7845
-4271
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ logs
1212
npm-debug.log*
1313
yarn-debug.log*
1414
yarn-error.log*
15+
yarn.lock
1516
lerna-debug.log*
1617
package-lock.json
1718

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33

44
# npx --no-install lint-staged
55
npm run pretty-quick
6+
npm run test

example/examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@
4949
"node"
5050
]
5151
}
52-
}
52+
}

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"license": "MIT",
33
"private": true,
44
"scripts": {
5-
"prepare": "husky install",
5+
"prepare": "husky install && cd ./test-ci && yarn install",
66
"⬇️⬇️⬇️⬇️⬇️ example::examples ⬇️⬇️⬇️⬇️⬇️": "▼▼▼▼▼ example::examples ▼▼▼▼▼",
77
"lib:build:examples": "lerna exec --scope @uiw/react-native -- tsbb build --disable-babel-option --no-esm --cjs ../../example/examples/lib",
88
"lib:watch:examples": "lerna exec --scope @uiw/react-native -- tsbb watch --disable-babel-option --no-esm --cjs ../../example/examples/lib",
@@ -11,8 +11,13 @@
1111
"lib:build:base": "lerna exec --scope @uiw/react-native -- tsbb build --disable-babel-option --no-esm --cjs ../../example/base/lib",
1212
"lib:watch:base": "lerna exec --scope @uiw/react-native -- tsbb watch --disable-babel-option --no-esm --cjs ../../example/base/lib",
1313
"⬆️⬆️⬆️⬆️⬆️ example::base ⬆️⬆️⬆️⬆️⬆️": "▲▲▲▲▲ example::base ▲▲▲▲▲",
14-
"watch": "npm run lib:watch & npm run lib:watch:base & npm run lib:watch:examples",
15-
"build": "npm run lib:build && npm run lib:build:base && npm run lib:build:examples",
14+
"⬇️⬇️⬇️⬇️⬇️ test-ci ⬇️⬇️⬇️⬇️⬇️": "▼▼▼▼▼ example::base ▼▼▼▼▼",
15+
"lib:build:test": "lerna exec --scope @uiw/react-native -- tsbb build --disable-babel-option --no-esm --cjs ../../test-ci/src/lib",
16+
"lib:watch:test": "lerna exec --scope @uiw/react-native -- tsbb watch --disable-babel-option --no-esm --cjs ../../test-ci/src/lib",
17+
"test": "cd ./test-ci && npm run test",
18+
"⬆️⬆️⬆️⬆️⬆️ test-ci ⬆️⬆️⬆️⬆️⬆️": "▲▲▲▲▲ example::base ▲▲▲▲▲",
19+
"watch": "npm run lib:watch & npm run lib:watch:base & npm run lib:watch:examples & npm run lib:watch:test",
20+
"build": "npm run lib:build && npm run lib:build:base && npm run lib:build:examples && npm run lib:build:test",
1621
">>>>>>>": ">>>>>>>",
1722
"lib:build": "lerna exec --scope @uiw/react-native -- tsbb build --disable-babel-option --no-esm",
1823
"lib:watch": "lerna exec --scope @uiw/react-native -- tsbb watch --disable-babel-option --no-esm",
@@ -73,4 +78,4 @@
7378
"**/webpack/**"
7479
]
7580
}
76-
}
81+
}

test-ci/App.tsx

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* Generated with the TypeScript template
6+
* https://github.com/react-native-community/react-native-template-typescript
7+
*
8+
* @format
9+
*/
10+
11+
import React, { type PropsWithChildren } from 'react';
12+
import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, useColorScheme, View } from 'react-native';
13+
14+
import {
15+
Colors,
16+
DebugInstructions,
17+
Header,
18+
LearnMoreLinks,
19+
ReloadInstructions,
20+
} from 'react-native/Libraries/NewAppScreen';
21+
22+
const Section: React.FC<
23+
PropsWithChildren<{
24+
title: string;
25+
}>
26+
> = ({ children, title }) => {
27+
const isDarkMode = useColorScheme() === 'dark';
28+
return (
29+
<View style={styles.sectionContainer}>
30+
<Text
31+
style={[
32+
styles.sectionTitle,
33+
{
34+
color: isDarkMode ? Colors.white : Colors.black,
35+
},
36+
]}
37+
>
38+
{title}
39+
</Text>
40+
<Text
41+
style={[
42+
styles.sectionDescription,
43+
{
44+
color: isDarkMode ? Colors.light : Colors.dark,
45+
},
46+
]}
47+
>
48+
{children}
49+
</Text>
50+
</View>
51+
);
52+
};
53+
54+
const App = () => {
55+
const isDarkMode = useColorScheme() === 'dark';
56+
57+
const backgroundStyle = {
58+
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
59+
};
60+
61+
return (
62+
<SafeAreaView style={backgroundStyle}>
63+
<StatusBar
64+
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
65+
backgroundColor={backgroundStyle.backgroundColor}
66+
/>
67+
<ScrollView contentInsetAdjustmentBehavior="automatic" style={backgroundStyle}>
68+
<Header />
69+
<View
70+
style={{
71+
backgroundColor: isDarkMode ? Colors.black : Colors.white,
72+
}}
73+
>
74+
<Section title="Step One">
75+
Edit <Text style={styles.highlight}>App.tsx</Text> to change this screen and then come back to see your
76+
edits.
77+
</Section>
78+
<Section title="See Your Changes">
79+
<ReloadInstructions />
80+
</Section>
81+
<Section title="Debug">
82+
<DebugInstructions />
83+
</Section>
84+
<Section title="Learn More">Read the docs to discover what to do next:</Section>
85+
<LearnMoreLinks />
86+
</View>
87+
</ScrollView>
88+
</SafeAreaView>
89+
);
90+
};
91+
92+
const styles = StyleSheet.create({
93+
sectionContainer: {
94+
marginTop: 32,
95+
paddingHorizontal: 24,
96+
},
97+
sectionTitle: {
98+
fontSize: 24,
99+
fontWeight: '600',
100+
},
101+
sectionDescription: {
102+
marginTop: 8,
103+
fontSize: 18,
104+
fontWeight: '400',
105+
},
106+
highlight: {
107+
fontWeight: '700',
108+
},
109+
});
110+
111+
export default App;

test-ci/Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby '2.7.5'
5+
6+
gem 'cocoapods', '~> 1.11', '>= 1.11.2'

test-ci/_bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

test-ci/_node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

test-ci/_ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.5

test-ci/android/app/_BUCK

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# To learn about Buck see [Docs](https://buckbuild.com/).
2+
# To run your application with Buck:
3+
# - install Buck
4+
# - `npm start` - to start the packager
5+
# - `cd android`
6+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8+
# - `buck install -r android/app` - compile, install and run application
9+
#
10+
11+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12+
13+
lib_deps = []
14+
15+
create_aar_targets(glob(["libs/*.aar"]))
16+
17+
create_jar_targets(glob(["libs/*.jar"]))
18+
19+
android_library(
20+
name = "all-libs",
21+
exported_deps = lib_deps,
22+
)
23+
24+
android_library(
25+
name = "app-code",
26+
srcs = glob([
27+
"src/main/java/**/*.java",
28+
]),
29+
deps = [
30+
":all-libs",
31+
":build_config",
32+
":res",
33+
],
34+
)
35+
36+
android_build_config(
37+
name = "build_config",
38+
package = "com.testjest",
39+
)
40+
41+
android_resource(
42+
name = "res",
43+
package = "com.testjest",
44+
res = "src/main/res",
45+
)
46+
47+
android_binary(
48+
name = "app",
49+
keystore = "//android/keystores:debug",
50+
manifest = "src/main/AndroidManifest.xml",
51+
package_type = "debug",
52+
deps = [
53+
":app-code",
54+
],
55+
)

0 commit comments

Comments
 (0)