forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoals_api_defaults_test.dart
More file actions
44 lines (40 loc) · 1.25 KB
/
Copy pathgoals_api_defaults_test.dart
File metadata and controls
44 lines (40 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import 'package:flutter_test/flutter_test.dart';
import 'package:omi/backend/http/api/goals.dart';
void main() {
test('Goal.fromJson backfills required canonical fields for sparse legacy payloads', () {
final goal = Goal.fromJson({
'id': 'goal_legacy',
'title': 'Read more',
'is_active': true,
'created_at': '2026-01-01T00:00:00Z',
});
expect(goal.id, 'goal_legacy');
expect(goal.title, 'Read more');
expect(goal.goalType, 'scale');
expect(goal.targetValue, 0);
expect(goal.maxValue, 10);
expect(goal.isActive, isTrue);
});
test('Goal.fromJson parses qualitative goals with metric null', () {
final goal = Goal.fromJson({
'id': 'goal_qualitative',
'goal_id': 'goal_qualitative',
'title': 'Launch desktop',
'desired_outcome': 'Ship a trustworthy release',
'status': 'background',
'source': 'user',
'metric': null,
'target_value': 0,
'current_value': 0,
'min_value': 0,
'max_value': 0,
'goal_type': 'scale',
'is_active': true,
'created_at': '2026-01-01T00:00:00Z',
'updated_at': '2026-01-01T00:00:00Z',
});
expect(goal.id, 'goal_qualitative');
expect(goal.targetValue, 0);
expect(goal.maxValue, 0);
});
}