Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2020
PPL-C
PPTI-Mobile Apps Monitoring Wabah Tuberkolosis
Neza-Mobile
Commits
357a2e61
Commit
357a2e61
authored
Apr 09, 2020
by
Josh Sudung
Browse files
Integrate log activity with investigation case edit form
parent
a5b84ae0
Changes
34
Hide whitespace changes
Inline
Side-by-side
debug.log
0 → 100644
View file @
357a2e61
[0408/032353.859:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0408/032353.880:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0408/032353.880:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0408/032353.881:ERROR:crash_report_database_win.cc(469)] failed to stat report
src/App/index.tsx
View file @
357a2e61
...
...
@@ -18,10 +18,10 @@ import {
}
from
'
scenes
'
;
import
{
Dimensions
}
from
'
react-native
'
;
import
initialCacheState
,
{
CacheType
,
SetCacheType
,
CacheType
}
from
'
contexts/AppContext/cache
'
;
import
{
useMainService
,
LocalStorage
}
from
'
services
'
import
Log
from
'
components/Log
'
;
const
StyledApp
=
styled
.
SafeAreaView
`
height: 100%;
...
...
@@ -48,10 +48,6 @@ declare global {
type
TokenType
=
string
;
type
SetTokenType
=
React
.
Dispatch
<
React
.
SetStateAction
<
TokenType
>>
;
type
CacheType
=
{
string
?:
any
;
};
type
SetCacheType
=
React
.
Dispatch
<
React
.
SetStateAction
<
CacheType
>>
;
interface
GlobalProps
{
vw
:
number
;
...
...
@@ -61,7 +57,7 @@ declare global {
};
setToken
:
SetTokenType
;
cache
:
CacheType
;
setCache
:
SetCacheType
;
setCache
:
(
object
)
=>
void
;
isAuthenticated
:
boolean
;
}
}
...
...
@@ -82,6 +78,28 @@ const theme: ThemeProps = {
vh
:
Dimensions
.
get
(
'
window
'
).
height
,
};
enum
CacheActionType
{
Update
=
"
Update
"
}
type
CacheAction
=
|
{
type
:
CacheActionType
.
Update
;
data
:
object
;
}
function
cacheReducer
(
oldCache
:
CacheType
,
action
:
CacheAction
):
CacheType
{
switch
(
action
.
type
)
{
case
CacheActionType
.
Update
:
return
{
...
oldCache
,
...
action
.
data
,
}
default
:
return
oldCache
}
}
const
App
=
()
=>
{
const
[
cache
,
setCache
]
=
useState
<
CacheType
>
(
initialCacheState
);
const
[
token
,
setToken
]
=
useState
();
...
...
@@ -104,7 +122,12 @@ const App = () => {
vh
:
Dimensions
.
get
(
'
window
'
).
height
,
// For caching
cache
,
setCache
,
setCache
:
(
data
)
=>
{
cacheDispatch
({
type
:
CacheActionType
.
Update
,
data
,
})
},
};
useEffect
(()
=>
{
...
...
@@ -169,6 +192,7 @@ const App = () => {
name
=
"officer-signup-finish"
component
=
{
OfficerSignupFormFinishPage
}
/>
<
Stack
.
Screen
name
=
"log"
component
=
{
Log
}
/>
</
Stack
.
Navigator
>
</
NavigationContainer
>
</
StyledApp
>
...
...
src/components/CategoryButton/__snapshots__/index.test.tsx.snap
View file @
357a2e61
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`
renders correctly
1`] = `
exports[`
CategoryButton tests Should change value after set value from outside
1`] = `
<View
axis={2}
style={
...
...
@@ -68,6 +68,404 @@ exports[`renders correctly 1`] = `
]
}
/>
<View
style={
Array [
Object {
"flexDirection": "row",
},
Object {},
]
}
>
<View
onMoveShouldSetResponder={[Function]}
onMoveShouldSetResponderCapture={[Function]}
onResponderEnd={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderReject={[Function]}
onResponderRelease={[Function]}
onResponderStart={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
onStartShouldSetResponderCapture={[Function]}
style={
Object {
"flex": 1,
}
}
>
<View
onLayout={[Function]}
style={
Object {
"backgroundColor": "#FAFAFA",
"borderRadius": 4,
"height": 30,
}
}
>
<View
style={
Object {
"borderColor": "#C9C9C9",
"borderRadius": 4,
"borderWidth": 0,
"flex": 1,
"flexDirection": "row",
}
}
>
<View
accessible={true}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"opacity": 1,
}
}
>
<Text
style={
Array [
Object {
"backgroundColor": "transparent",
"color": "#5F5F5F",
"fontSize": 14,
"fontWeight": "bold",
"textAlign": "center",
},
Object {},
]
}
>
Laki-laki
</Text>
</View>
<View
accessible={true}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"opacity": 1,
}
}
>
<Text
style={
Array [
Object {
"backgroundColor": "transparent",
"color": "#FFFFFF",
"fontSize": 14,
"fontWeight": "bold",
"textAlign": "center",
},
Object {},
]
}
>
Perempuan
</Text>
</View>
</View>
</View>
</View>
</View>
</View>
`;
exports[`CategoryButton tests renders correctly 1`] = `
<View
axis={2}
style={
Array [
Object {
"alignItems": "flex-start",
"backgroundColor": "transparent",
"borderBottomColor": "black",
"borderBottomWidth": 0,
"borderLeftColor": "black",
"borderLeftWidth": 0,
"borderRadius": 0,
"borderRightColor": "black",
"borderRightWidth": 0,
"borderTopColor": "black",
"borderTopWidth": 0,
"flexDirection": "column",
"flexGrow": 0,
"flexShrink": 0,
"flexWrap": "nowrap",
"height": "auto",
"justifyContent": "flex-start",
"paddingBottom": 0,
"paddingLeft": 0,
"paddingRight": 0,
"paddingTop": 0,
"width": "auto",
},
]
}
>
<Text
fontSize="16px"
fontWeight="Bold"
style={
Array [
Object {
"color": "black",
"fontFamily": "Dosis-Bold",
"fontSize": 16,
"textAlign": "left",
"width": "auto",
},
]
}
>
Jenis Kelamin
</Text>
<View
paddingBottom={6}
paddingLeft={0}
paddingRight={0}
paddingTop={6}
style={
Array [
Object {
"flexBasis": "auto",
"flexGrow": 0,
"flexShrink": 0,
"paddingBottom": 6,
"paddingLeft": 0,
"paddingRight": 0,
"paddingTop": 6,
},
]
}
/>
<View
style={
Array [
Object {
"flexDirection": "row",
},
Object {},
]
}
>
<View
onMoveShouldSetResponder={[Function]}
onMoveShouldSetResponderCapture={[Function]}
onResponderEnd={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderReject={[Function]}
onResponderRelease={[Function]}
onResponderStart={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
onStartShouldSetResponderCapture={[Function]}
style={
Object {
"flex": 1,
}
}
>
<View
onLayout={[Function]}
style={
Object {
"backgroundColor": "#FAFAFA",
"borderRadius": 4,
"height": 30,
}
}
>
<View
style={
Object {
"borderColor": "#C9C9C9",
"borderRadius": 4,
"borderWidth": 0,
"flex": 1,
"flexDirection": "row",
}
}
>
<View
accessible={true}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"opacity": 1,
}
}
>
<Text
style={
Array [
Object {
"backgroundColor": "transparent",
"color": "#FFFFFF",
"fontSize": 14,
"fontWeight": "bold",
"textAlign": "center",
},
Object {},
]
}
>
Laki-laki
</Text>
</View>
<View
accessible={true}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"opacity": 1,
}
}
>
<Text
style={
Array [
Object {
"backgroundColor": "transparent",
"color": "#5F5F5F",
"fontSize": 14,
"fontWeight": "bold",
"textAlign": "center",
},
Object {},
]
}
>
Perempuan
</Text>
</View>
</View>
</View>
</View>
</View>
</View>
`;
exports[`CategoryButton tests should be okay if there is not onClick function 1`] = `
<View
axis={2}
style={
Array [
Object {
"alignItems": "flex-start",
"backgroundColor": "transparent",
"borderBottomColor": "black",
"borderBottomWidth": 0,
"borderLeftColor": "black",
"borderLeftWidth": 0,
"borderRadius": 0,
"borderRightColor": "black",
"borderRightWidth": 0,
"borderTopColor": "black",
"borderTopWidth": 0,
"flexDirection": "column",
"flexGrow": 0,
"flexShrink": 0,
"flexWrap": "nowrap",
"height": "auto",
"justifyContent": "flex-start",
"paddingBottom": 0,
"paddingLeft": 0,
"paddingRight": 0,
"paddingTop": 0,
"width": "auto",
},
]
}
>
<Text
fontSize="16px"
fontWeight="Bold"
style={
Array [
Object {
"color": "black",
"fontFamily": "Dosis-Bold",
"fontSize": 16,
"textAlign": "left",
"width": "auto",
},
]
}
>
Gender
</Text>
<View
paddingBottom={6}
paddingLeft={0}
paddingRight={0}
paddingTop={6}
style={
Array [
Object {
"flexBasis": "auto",
"flexGrow": 0,
"flexShrink": 0,
"paddingBottom": 6,
"paddingLeft": 0,
"paddingRight": 0,
"paddingTop": 6,
},
]
}
/>
<View
style={
Array [
...
...
src/components/CategoryButton/index.test.tsx
View file @
357a2e61
...
...
@@ -10,32 +10,81 @@ import CategoryButton from '.';
import
renderer
,
{
act
}
from
'
react-test-renderer
'
;
import
SwitchSelector
from
'
react-native-switch-selector
'
;
it
(
'
renders correctly
'
,
()
=>
{
const
options
=
[
{
label
:
'
Laki-laki
'
,
value
:
1
},
{
label
:
'
Perempuan
'
,
value
:
0
},
];
let
val
=
0
;
const
addVal
=
()
=>
val
++
;
const
inst
=
renderer
.
create
(
<
CategoryButton
name
=
"Jenis Kelamin"
label
=
"Jenis Kelamin"
options
=
{
options
}
onClick
=
{
()
=>
addVal
()
}
/>,
);
expect
(
inst
.
toJSON
()).
toMatchSnapshot
();
const
button
=
inst
.
root
.
findByType
(
SwitchSelector
);
describe
(
"
CategoryButton tests
"
,
()
=>
{
it
(
'
renders correctly
'
,
()
=>
{
const
options
=
[
{
label
:
'
Laki-laki
'
,
value
:
1
},
{
label
:
'
Perempuan
'
,
value
:
0
},
];
let
val
=
0
;
const
addVal
=
()
=>
val
++
;
const
inst
=
renderer
.
create
(
<
CategoryButton
name
=
"Jenis Kelamin"
options
=
{
options
}
onClick
=
{
()
=>
addVal
()
}
/>,
);
expect
(
inst
.
toJSON
()).
toMatchSnapshot
();
const
button
=
inst
.
root
.
findByType
(
SwitchSelector
);
act
(()
=>
{
button
.
props
.
onPress
();
});
expect
(
val
).
toBe
(
1
);
});
act
(()
=>
{
button
.
props
.
onPress
();
it
(
'
should be okay if there is not onClick function
'
,
()
=>
{
const
options
=
[
{
label
:
'
Laki-laki
'
,
value
:
1
},
{
label
:
'
Perempuan
'
,
value
:
0
},
];
const
inst
=
renderer
.
create
(
<
CategoryButton
name
=
"Gender"
options
=
{
options
}
/>,
);
expect
(
inst
.
toJSON
()).
toMatchSnapshot
();
});
expect
(
val
).
toBe
(
1
);
});
it
(
"
Should change value after set value from outside
"
,
()
=>
{
const
options
=
[
{
label
:
'
Laki-laki
'
,
value
:
1
},
{
label
:
'
Perempuan
'
,
value
:
0
},
];
let
val
;
const
inst
=
renderer
.
create
(
<
CategoryButton
name
=
"Jenis Kelamin"
value
=
{
0
}
options
=
{
options
}
onClick
=
{
(
newValue
)
=>
val
=
newValue
}
/>,
);
expect
(
inst
.
toJSON
()).
toMatchSnapshot
();
const
button
=
inst
.
root
.
findByType
(
SwitchSelector
);
let
numberIteration
=
1
const
tolerance
=
100
while
(
val
!==
0
&&
numberIteration
<
tolerance
)
{
act
(()
=>
{
button
.
props
.
onPress
();
});
numberIteration
++
}
expect
(
val
).
toBe
(
0
);
})
})
src/components/CategoryButton/index.tsx
View file @
357a2e61
import
React
from
'
react
'