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

akvo / nmis-mobile / 5606797450

20 Jul 2023 04:11AM UTC coverage: 73.195% (-0.3%) from 73.446%
5606797450

push

github

wayangalihpratama
[#56] Fix get started page snapshot

368 of 535 branches covered (68.79%)

Branch coverage included in aggregate %.

828 of 1099 relevant lines covered (75.34%)

8.89 hits per line

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

86.96
/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) => {
7✔
9
    const filteredQuestions = questionGroup.question.filter((q) => q.required);
35✔
10
    return (
21✔
11
      filteredQuestions
12
        .map((question) => {
13
          if (values?.[question.id]) {
28✔
14
            return true;
6✔
15
          }
16
          return false;
22✔
17
        })
18
        .filter((x) => x).length === filteredQuestions.length
28✔
19
    );
20
  });
21
};
22

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

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

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

67
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