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

akvo / nmis-mobile / 5686979043

28 Jul 2023 12:57AM UTC coverage: 78.007% (-0.1%) from 78.111%
5686979043

Pull #73

github

web-flow
Merge 47dba2dc7 into 8c6a02091
Pull Request #73: Feature/72 saving draft form and clear response

559 of 756 branches covered (73.94%)

Branch coverage included in aggregate %.

110 of 110 new or added lines in 5 files covered. (100.0%)

1140 of 1422 relevant lines covered (80.17%)

11.82 hits per line

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

70.27
/app/src/form/support/SaveDropdownMenu.js
1
import React from 'react';
2
import { Button } from '@rneui/themed';
3
import { Menu, MenuItem, MenuDivider } from 'react-native-material-menu';
4
import { StyleSheet } from 'react-native';
5
import { config } from '../../pages/Settings/config';
6
import DialogForm from '../../pages/Settings/DialogForm';
7
import { UIState } from '../../store';
8

9
const userInterfaceConfigId = 2;
16✔
10

11
const SaveDropdownMenu = ({ anchor, visible, setVisible, handleOnSaveAndExit, handleOnExit }) => {
16✔
12
  const [showLanguageSelectionDialog, setShowLanguageSelectionDialog] = React.useState(false);
24✔
13

14
  const languageSelectionDialogConfig = React.useMemo(() => {
24✔
15
    const findFieldsConfig = config.find((x) => x.id === userInterfaceConfigId)?.fields || [];
28!
16
    return findFieldsConfig.find((x) => x.name === 'lang') || {};
14!
17
  }, []);
18

19
  const handleOnOk = (value) => {
24✔
20
    UIState.update((s) => {
1✔
21
      s.lang = value;
×
22
    });
23
    setShowLanguageSelectionDialog(false);
1✔
24
  };
25

26
  return (
24✔
27
    <>
28
      <Menu
29
        animationDuration={0}
30
        visible={visible}
31
        anchor={
32
          anchor || (
37✔
33
            <Button
34
              testID="anchor-dropdown-menu"
35
              onPress={() => {
36
                if (setVisible) {
1!
37
                  setVisible(true);
1✔
38
                }
39
              }}
40
            >
41
              Show Menu
42
            </Button>
43
          )
44
        }
45
        onRequestClose={() => {
46
          if (setVisible) {
×
47
            return setVisible(false);
×
48
          }
49
        }}
50
        testID="save-dropdown-menu"
51
        style={styles.dropdownContainer}
52
      >
53
        <MenuItem
54
          onPress={() => {
55
            if (handleOnSaveAndExit) {
1!
56
              return handleOnSaveAndExit();
1✔
57
            }
58
          }}
59
          testID="save-and-exit-menu-item"
60
        >
61
          Save and Exit
62
        </MenuItem>
63
        <MenuItem
64
          onPress={() => {
65
            if (handleOnExit) {
1!
66
              return handleOnExit();
1✔
67
            }
68
          }}
69
          testID="exit-without-saving-menu-item"
70
        >
71
          Exit without Saving
72
        </MenuItem>
73
        <MenuDivider />
74
        <MenuItem
75
          testID="language-selection-menu-item"
76
          onPress={() => {
77
            setShowLanguageSelectionDialog(true);
2✔
78
            setVisible(false);
2✔
79
          }}
80
        >
81
          Language Selection
82
        </MenuItem>
83
      </Menu>
84
      <DialogForm
85
        onOk={handleOnOk}
86
        onCancel={() => setShowLanguageSelectionDialog(false)}
×
87
        showDialog={showLanguageSelectionDialog}
88
        edit={languageSelectionDialogConfig}
89
      />
90
    </>
91
  );
92
};
93

94
const styles = StyleSheet.create({
16✔
95
  dropdownContainer: {
96
    marginTop: 50,
97
  },
98
});
99

100
export default SaveDropdownMenu;
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

© 2026 Coveralls, Inc