Skip to content

Commit a33a29e

Browse files
authored
Merge pull request #6 from DanielSanudo/detox_tests
Detox tests added
2 parents 8604024 + d34dc08 commit a33a29e

25 files changed

+3450
-8850
lines changed

.eslintrc

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
{
2-
"extends": "@react-native-community"
2+
"extends": "@react-native-community",
3+
"globals": {
4+
"expect": true,
5+
"element": true,
6+
"by": true,
7+
"device": true,
8+
"beforeAll": true,
9+
"beforeEach": true,
10+
"afterAll": true,
11+
"jest": true,
12+
"jasmine": true
13+
}
314
}

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
###
44

5+
- [#6] Detox tests added
56
- [#5] Adjust CHANGELOG.md to have links at bottom of markdown
67
- [#4] Fixing iOS React import and cleaning iOS example project
78
- [#3] Using @react-native-community/eslint-config
89

910
[#3]: https://github.com/react-native-community/react-native-datetimepicker/pull/3
1011
[#4]: https://github.com/react-native-community/react-native-datetimepicker/pull/4
11-
[#4]: https://github.com/react-native-community/react-native-datetimepicker/pull/5
12+
[#5]: https://github.com/react-native-community/react-native-datetimepicker/pull/5
13+
[#6]: https://github.com/react-native-community/react-native-datetimepicker/pull/6

example/.buckconfig

-6
This file was deleted.

example/.flowconfig

-70
This file was deleted.

example/.watchmanconfig

-1
This file was deleted.

example/App.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React, {Component} from 'react';
22
import {StyleSheet, View, Text, Button, Platform} from 'react-native';
3+
import moment from 'moment';
34
import DateTimePicker from 'react-native-datetimepicker';
45

56
type Props = {};
67
export default class App extends Component<Props> {
78
state = {
8-
date: new Date('2020-06-12T14:42:42'),
9+
date: new Date(1598051730000),
910
mode: 'date',
1011
show: false,
1112
}
@@ -38,17 +39,23 @@ export default class App extends Component<Props> {
3839
const { show, date, mode } = this.state;
3940

4041
return (
41-
<View style={styles.container}>
42+
<View testID="appRootView" style={styles.container}>
4243
<View style={styles.header}>
4344
<Text style={styles.text}>Example DateTime Picker</Text>
4445
</View>
4546
<View style={styles.button}>
46-
<Button onPress={this.datepicker} title="Show date picker!" />
47+
<Button testID="datePickerButton" onPress={this.datepicker} title="Show date picker!" />
4748
</View>
4849
<View style={styles.button}>
49-
<Button onPress={this.timepicker} title="Show time picker!" />
50+
<Button testID="timePickerButton" onPress={this.timepicker} title="Show time picker!" />
5051
</View>
51-
{ show && <DateTimePicker value={date} mode={mode} is24Hour={true} display="default" onChange={this.setDate} /> }
52+
<View style={styles.header}>
53+
<Text testID="dateTimeText" style={styles.dateTimeText}>
54+
{ mode === 'time' && moment.utc(date).format('HH:mm') }
55+
{ mode === 'date' && moment.utc(date).format('MM/DD/YYYY') }
56+
</Text>
57+
</View>
58+
{ show && <DateTimePicker testID="dateTimePicker" timeZoneOffsetInMinutes={0} value={date} mode={mode} is24Hour={true} display="default" onChange={this.setDate} /> }
5259
</View>
5360
);
5461
}
@@ -72,4 +79,8 @@ const styles = StyleSheet.create({
7279
fontSize: 20,
7380
fontWeight: 'bold',
7481
},
82+
dateTimeText: {
83+
fontSize: 16,
84+
fontWeight: 'normal',
85+
},
7586
});

example/android/app/build.gradle

+19-3
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ import com.android.build.OutputFile
7373
*/
7474

7575
project.ext.react = [
76-
entryFile: "index.js"
76+
entryFile: "example/index.js",
77+
root: "../../../"
7778
]
7879

79-
apply from: "../../node_modules/react-native/react.gradle"
80+
apply from: "../../../node_modules/react-native/react.gradle"
8081

8182
/**
8283
* Set this to true to create two separate APKs instead of one:
@@ -95,7 +96,7 @@ def enableProguardInReleaseBuilds = false
9596

9697
android {
9798
compileSdkVersion rootProject.ext.compileSdkVersion
98-
99+
99100
compileOptions {
100101
sourceCompatibility JavaVersion.VERSION_1_8
101102
targetCompatibility JavaVersion.VERSION_1_8
@@ -107,6 +108,18 @@ android {
107108
targetSdkVersion rootProject.ext.targetSdkVersion
108109
versionCode 1
109110
versionName "1.0"
111+
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
112+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
113+
}
114+
signingConfigs {
115+
release {
116+
if (project.hasProperty('EXAMPLE_APP_STORE_FILE')) {
117+
storeFile file(EXAMPLE_APP_STORE_FILE)
118+
storePassword EXAMPLE_APP_STORE_PASSWORD
119+
keyAlias EXAMPLE_APP_KEY_ALIAS
120+
keyPassword EXAMPLE_APP_KEY_PASSWORD
121+
}
122+
}
110123
}
111124
splits {
112125
abi {
@@ -118,6 +131,7 @@ android {
118131
}
119132
buildTypes {
120133
release {
134+
signingConfig signingConfigs.release
121135
minifyEnabled enableProguardInReleaseBuilds
122136
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
123137
}
@@ -142,6 +156,8 @@ dependencies {
142156
implementation fileTree(dir: "libs", include: ["*.jar"])
143157
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
144158
implementation "com.facebook.react:react-native:+" // From node_modules
159+
androidTestImplementation('com.wix:detox:+') { transitive = true }
160+
androidTestImplementation 'junit:junit:4.12'
145161
}
146162

147163
// Run this once to be able to run the application with BUCK
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example;
2+
3+
import com.wix.detox.Detox;
4+
5+
import org.junit.Rule;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
9+
import androidx.test.ext.junit.runners.AndroidJUnit4;
10+
import androidx.test.filters.LargeTest;
11+
import androidx.test.rule.ActivityTestRule;
12+
13+
@RunWith(AndroidJUnit4.class)
14+
@LargeTest
15+
public class DetoxTest {
16+
17+
@Rule
18+
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
19+
20+
@Test
21+
public void runDetoxTests() {
22+
Detox.runTests(mActivityRule);
23+
}
24+
}

example/android/app/src/main/java/com/example/MainApplication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected List<ReactPackage> getPackages() {
3131

3232
@Override
3333
protected String getJSMainModuleName() {
34-
return "index";
34+
return "example/index";
3535
}
3636
};
3737

example/android/build.gradle

+11-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
buildscript {
44
ext {
5+
kotlinVersion = "1.3.0"
56
buildToolsVersion = "28.0.3"
6-
minSdkVersion = 16
7+
minSdkVersion = 18
78
compileSdkVersion = 28
8-
targetSdkVersion = 28
9+
targetSdkVersion = 27
910
supportLibVersion = "28.0.0"
1011
}
1112
repositories {
@@ -14,6 +15,7 @@ buildscript {
1415
}
1516
dependencies {
1617
classpath 'com.android.tools.build:gradle:3.3.1'
18+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1719

1820
// NOTE: Do not place your application dependencies here; they belong
1921
// in the individual module build.gradle files
@@ -26,9 +28,9 @@ allprojects {
2628
doLast {
2729
configurations.findAll().each { config ->
2830
if (config.name.contains("minReactNative") && config.canBeResolved) {
29-
print config.name
30-
print '\n'
31-
config.files
31+
print config.name
32+
print '\n'
33+
config.files
3234
}
3335
}
3436
}
@@ -40,7 +42,10 @@ allprojects {
4042
jcenter()
4143
maven {
4244
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
43-
url "$rootDir/../node_modules/react-native/android"
45+
url "$rootDir/../../node_modules/react-native/android"
46+
}
47+
maven {
48+
url "$rootDir/../../node_modules/detox/Detox-android"
4449
}
4550
}
4651
}

example/android/gradle.properties

+5
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@
1818
# org.gradle.parallel=true
1919
android.useAndroidX=true
2020
android.enableJetifier=true
21+
22+
EXAMPLE_APP_STORE_FILE=release.keystore
23+
EXAMPLE_APP_KEY_ALIAS=androiddebugkey
24+
EXAMPLE_APP_STORE_PASSWORD=android
25+
EXAMPLE_APP_KEY_PASSWORD=android

example/babel.config.js

-13
This file was deleted.

example/e2e/config.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"setupFilesAfterEnv": ["./init.js"],
3+
"testEnvironment": "node",
4+
"reporters": ["detox/runners/jest/streamlineReporter"],
5+
"verbose": true
6+
}

0 commit comments

Comments
 (0)