• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

akvo / nmis-mobile / 5307859313

19 Jun 2023 04:34AM UTC coverage: 58.824% (-41.2%) from 100.0%
5307859313

Pull #9

github

web-flow
Merge 119546cb3 into 5b9af76bd
Pull Request #9: Tryout/8 sqlite

1 of 6 branches covered (16.67%)

Branch coverage included in aggregate %.

26 of 26 new or added lines in 3 files covered. (100.0%)

19 of 28 relevant lines covered (67.86%)

1.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.17
/app/App.js
1
import React from 'react';
2
import { SafeAreaView, StyleSheet, TextInput, Button } from 'react-native';
3
import { openDatabase, createExampleTable, addExample, getAllExamples } from './src/database';
4

5
const db = openDatabase();
1✔
6

7
function useForceUpdate() {
8
  const [value, setValue] = React.useState(0);
5✔
9
  return [() => setValue(value + 1), value];
5✔
10
}
11

12
const App = () => {
1✔
13
  const [text, onChangeText] = React.useState('Testing');
5✔
14
  const [number, onChangeNumber] = React.useState('');
5✔
15
  const [forceUpdate, forceUpdateId] = useForceUpdate();
5✔
16

17
  React.useEffect(() => {
5✔
18
    db.transaction((tx) => {
3✔
19
      tx.executeSql(createExampleTable);
×
20
    });
21
  }, []);
22

23
  const handleOnAdd = () => {
5✔
24
    if (text === null || text === '') {
×
25
      return false;
×
26
    }
27
    db.transaction(
×
28
      (tx) => {
29
        tx.executeSql(addExample, [text, number, JSON.stringify(['Devin', 'Dan', 'Dominic'])]);
×
30
        tx.executeSql(getAllExamples, [], (_, { rows }) =>
×
31
          console.log('examples: ', JSON.stringify(rows)),
×
32
        );
33
      },
34
      null,
35
      forceUpdate,
36
    );
37
  };
38

39
  return (
5✔
40
    <SafeAreaView>
41
      <TextInput style={styles.input} onChangeText={onChangeText} value={text} testID="inputText" />
42
      <TextInput
43
        style={styles.input}
44
        onChangeText={onChangeNumber}
45
        value={number}
46
        placeholder="Please Input"
47
        keyboardType="numeric"
48
        testID="inputNumber"
49
      />
50
      <Button
51
        onPress={handleOnAdd}
52
        title="Add"
53
        color="#841584"
54
        accessibilityLabel="Add new example"
55
      />
56
    </SafeAreaView>
57
  );
58
};
59

60
const styles = StyleSheet.create({
1✔
61
  input: {
62
    height: 40,
63
    margin: 12,
64
    borderWidth: 1,
65
    padding: 10,
66
  },
67
});
68

69
export default App;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc