Skip to content

Commit

Permalink
Test changing working time
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mabe committed Jul 28, 2023
1 parent 665e6ff commit 593aada
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/create_workout/set_timings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class _SetTimingsState extends State<SetTimings> {
children: [
const Icon(Icons.fitness_center),
IconButton(
key: const Key('work-decrement'),
icon: const Icon(Icons.remove),
onPressed: () => setState(() {
final newValue = exerciseTime - 1;
Expand All @@ -106,6 +107,7 @@ class _SetTimingsState extends State<SetTimings> {
),
Text('Working time: $exerciseTime seconds'),
IconButton(
key: const Key('work-increment'),
icon: const Icon(Icons.add),
onPressed: () => setState(() {
final newValue = exerciseTime + 1;
Expand All @@ -125,6 +127,7 @@ class _SetTimingsState extends State<SetTimings> {
children: [
const Icon(Icons.snooze),
IconButton(
key: const Key('rest-decrement'),
icon: const Icon(Icons.remove),
onPressed: () => setState(() {
final newValue = restTime - 1;
Expand All @@ -134,6 +137,7 @@ class _SetTimingsState extends State<SetTimings> {
),
Text('Rest time: $restTime seconds'),
IconButton(
key: const Key('rest-increment'),
icon: const Icon(Icons.add),
onPressed: () => setState(() {
final newValue = restTime + 1;
Expand Down
26 changes: 25 additions & 1 deletion test/workout_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:openhiit/main.dart';

void main() {
testWidgets('Load add workout smoke test', (WidgetTester tester) async {
testWidgets('Add workout smoke test', (WidgetTester tester) async {
String workoutName = "Test workout 1";

// Build our app and trigger a frame.
Expand Down Expand Up @@ -68,5 +68,29 @@ void main() {

expect(find.text('testing $i'), findsOneWidget);
}

// Tap to go to the next page.
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();

// Reduce working time.
for (var i = 0; i < 2; i++) {
// Reduce the working time by 2.
await tester.tap(find.byKey(const Key('work-decrement')));
await tester.pumpAndSettle();
}

// Work time should be 18.
expect(find.text('18'), findsOneWidget);

// Increase working time.
for (var i = 0; i < 2; i++) {
// Increase the working time by 3.
await tester.tap(find.byKey(const Key('work-increment')));
await tester.pumpAndSettle();
}

// Work time should be 21.
expect(find.text('21'), findsOneWidget);
});
}

0 comments on commit 593aada

Please sign in to comment.