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

akvo / nmis-mobile / 5584204952

18 Jul 2023 06:46AM UTC coverage: 72.915% (+2.2%) from 70.668%
5584204952

Pull #50

github

web-flow
Merge 62a70bc2b into 79adab1f4
Pull Request #50: Feature/46 question group list

337 of 500 branches covered (67.4%)

Branch coverage included in aggregate %.

43 of 43 new or added lines in 7 files covered. (100.0%)

791 of 1047 relevant lines covered (75.55%)

8.21 hits per line

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

85.0
/app/src/form/support/QuestionGroupList.js
1
import React, { useMemo } from 'react';
2
import { View } from 'react-native';
3
import { Text, Divider } from '@rneui/themed';
4
import QuestionGroupListItem from './QuestionGroupListItem';
5
import { styles } from '../styles';
6

7
export const checkCompleteQuestionGroup = (form, values) => {
13✔
8
  return form.question_group.map((questionGroup) => {
5✔
9
    const filteredQuestions = questionGroup.question.filter((q) => q.required);
25✔
10
    return (
15✔
11
      filteredQuestions
12
        .map((question) => {
13
          if (values?.[question.id]) {
20✔
14
            return true;
5✔
15
          }
16
          return false;
15✔
17
        })
18
        .filter((x) => x).length === filteredQuestions.length
20✔
19
    );
20
  });
21
};
22

23
const QuestionGroupList = ({
13✔
24
  form,
25
  values = {},
1✔
26
  activeQuestionGroup,
27
  setActiveQuestionGroup,
28
  setShowQuestionGroupList,
29
}) => {
30
  const completedQuestionGroup = useMemo(() => {
1✔
31
    return checkCompleteQuestionGroup(form, values);
1✔
32
  });
33

34
  const handleOnPress = (questionGroupId) => {
1✔
35
    setActiveQuestionGroup(questionGroupId);
×
36
    setShowQuestionGroupList(false);
×
37
  };
38

39
  return (
1✔
40
    <View style={styles.questionGroupListContainer}>
41
      <Text style={styles.questionGroupListFormTitle} testID="form-name">
42
        {form.name}
43
      </Text>
44
      <Divider style={styles.divider} />
45
      <Text style={styles.questionGroupListDataPointName} testID="datapoint-name">
46
        Data Point name here
47
      </Text>
48
      <Divider style={styles.divider} />
49
      {form.question_group.map((questionGroup, qx) => (
50
        <QuestionGroupListItem
3✔
51
          key={questionGroup.id}
52
          name={questionGroup.name}
53
          active={activeQuestionGroup === questionGroup.id}
54
          completedQuestionGroup={completedQuestionGroup[qx]}
55
          onPress={() => handleOnPress(questionGroup.id)}
×
56
        />
57
      ))}
58
    </View>
59
  );
60
};
61

62
export default QuestionGroupList;
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