41 lines
1.3 KiB
Dart
41 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/changes/domain/change_kind.dart';
|
|
import 'package:pipelines_app/features/changes/domain/file_change.dart';
|
|
import 'package:pipelines_app/features/changes/widgets/file_diff_viewer.dart';
|
|
|
|
FileChange _file(String path) => FileChange(
|
|
path: path,
|
|
kind: ChangeKind.modified,
|
|
patch: '--- a/$path\n+++ b/$path\n@@ -1 +1 @@\n-a\n+b\n',
|
|
);
|
|
|
|
void main() {
|
|
testWidgets('left and right arrows step between changed files', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: FileDiffPage(
|
|
files: [_file('lib/one.dart'), _file('lib/two.dart')],
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('one.dart'), findsWidgets);
|
|
|
|
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('two.dart'), findsWidgets);
|
|
|
|
// The last file stays put; left goes back.
|
|
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('two.dart'), findsWidgets);
|
|
await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('one.dart'), findsWidgets);
|
|
});
|
|
}
|