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

wger-project / react / 25391281613

05 May 2026 05:17PM UTC coverage: 71.633% (-2.9%) from 74.492%
25391281613

push

github

rolandgeider
Export coverage in lcov, needed for the coveralls report

2022 of 3078 branches covered (65.69%)

Branch coverage included in aggregate %.

4334 of 5795 relevant lines covered (74.79%)

29.02 hits per line

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

92.86
/src/components/WorkoutRoutines/models/BaseConfig.ts
1
/* eslint-disable camelcase */
2

3
import { Adapter } from "@/utils/Adapter";
4

5
export interface BaseConfigEntryForm {
6
    // This value is only used to change the conditional validation.
7
    // This is kinda ugly but seems to be the cleanest way to do it
8
    forceInteger: boolean;
9

10
    edited: boolean;
11
    iteration: number;
12
    id: number | null;
13
    idMax: number | null;
14
    value: number | string;
15
    valueMax: number | string;
16
    operation: OperationType;
17
    operationMax: OperationType;
18
    step: StepType;
19
    stepMax: StepType;
20
    requirements: RequirementsType[];
21
    requirementsMax: RequirementsType[];
22
    repeat: boolean;
23
    repeatMax: boolean;
24
}
25

26
export const OPERATION_REPLACE = 'r';
91✔
27
export const OPERATION_ADD = '+';
91✔
28
export const OPERATION_SUBSTRACT = '-';
91✔
29

30
export const REQUIREMENTS_VALUES = ["weight", "repetitions", "rir", "rest"] as const;
91✔
31

32
export type OperationType = "+" | "-" | "r";
33
export type StepType = "abs" | "percent";
34
export type RequirementsType = typeof REQUIREMENTS_VALUES;
35

36

37
export const STEP_VALUES_SELECT = [
91✔
38
    { value: 'abs', 'label': 'Absolute' },
39
    { value: 'percent', 'label': 'Percent' },
40
];
41

42
export const OPERATION_VALUES_SELECT = [
91✔
43
    { value: OPERATION_ADD, label: 'Add' },
44
    { value: OPERATION_SUBSTRACT, label: 'Subtract' },
45
    { value: OPERATION_REPLACE, label: 'Replace' },
46
];
47

48
export const RIR_VALUES_SELECT_LIST = [
91✔
49
    { value: '', label: '-/-' },
50
    ...[0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4].map(value => ({ value: value, label: value.toString() })),
819✔
51
    { value: 4.5, label: '4+' }
52
];
53

54
export const RIR_VALUES_SELECT = [...RIR_VALUES_SELECT_LIST] as const;
91✔
55

56
export interface RuleRequirements {
57
    rules: RequirementsType[];
58
}
59

60
export class BaseConfig {
61
    id: number;
62
    slotEntryId: number;
63
    iteration: number;
64
    value: number;
65
    operation: OperationType;
66
    step: StepType;
67
    repeat: boolean;
68
    requirements: RuleRequirements | null;
69

70

71
    constructor(data: {
72
        id: number;
73
        slotEntryId: number;
74
        iteration: number;
75
        value: number;
76
        operation?: OperationType;
77
        step?: StepType;
78
        repeat?: boolean;
79
        requirements?: RuleRequirements | null;
80
    }) {
81
        this.id = data.id;
200✔
82
        this.slotEntryId = data.slotEntryId;
200✔
83
        this.iteration = data.iteration;
200✔
84
        this.value = data.value;
200✔
85
        this.operation = data.operation ?? 'r';
200✔
86
        this.step = data.step ?? 'abs';
200✔
87
        this.repeat = data.repeat ?? false;
200✔
88
        this.requirements = data.requirements ?? null;
200✔
89
    }
90

91
    get replace() {
92
        return this.operation === "r";
×
93
    }
94
}
95

96
export class BaseConfigAdapter implements Adapter<BaseConfig> {
97
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
    fromJson = (item: any) => new BaseConfig({
12✔
99
        id: item.id,
100
        slotEntryId: item.slot_entry,
101
        iteration: item.iteration,
102
        value: parseFloat(item.value),
103
        operation: item.operation,
104
        step: item.step,
105
        repeat: item.repeat,
106
        requirements: item.requirements
107
    });
108

109
    toJson = (item: BaseConfig) => ({
×
110
        slot_entry: item.slotEntryId,
111
        iteration: item.iteration,
112
        value: item.value,
113
        operation: item.operation,
114
        step: item.step,
115
        repeat: item.repeat,
116
        requirements: item.requirements,
117
    });
118
}
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