-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
858189f
commit 7723f8c
Showing
5 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,4 @@ app.*.map.json | |
/android/app/release | ||
|
||
.env | ||
test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:bloc_test/bloc_test.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:pilot_s3/widgets/path_chips/cubit/path_chips_cubit.dart'; | ||
|
||
void main() { | ||
group('PathChipsCubit', () { | ||
late PathChipsCubit pathChipsCubit; | ||
|
||
setUp(() { | ||
pathChipsCubit = PathChipsCubit(); | ||
}); | ||
test('isHovered in initial state is false', () { | ||
expect(pathChipsCubit.state, const PathChipsState(isHovered: false)); | ||
}); | ||
blocTest<PathChipsCubit, PathChipsState>( | ||
'emits [PathChipsState] when setHover is added.', | ||
build: () => PathChipsCubit(), | ||
act: (cubit) => cubit.setHover(true), | ||
expect: () => const <PathChipsState>[PathChipsState(isHovered: true)], | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:pilot_s3/widgets/path_chips/path_chips.dart'; | ||
|
||
void main() { | ||
testWidgets('Renders passed text to chips', (tester) async { | ||
const String testText = 'Chips label'; | ||
await tester.pumpWidget(MaterialApp( | ||
home: Scaffold( | ||
body: PathChips( | ||
label: testText, | ||
onTap: () {}, | ||
), | ||
), | ||
)); | ||
|
||
final labelFinder = find.text(testText); | ||
expect(labelFinder, findsOneWidget); | ||
}); | ||
|
||
testWidgets('Change chips color after hover', (tester) async { | ||
await tester.pumpWidget(MaterialApp( | ||
home: Scaffold( | ||
body: PathChips( | ||
onTap: () {}, | ||
), | ||
), | ||
)); | ||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is Container && widget.color == Colors.grey[150]), | ||
findsOneWidget); | ||
|
||
final gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); | ||
await gesture.addPointer(location: Offset.zero); | ||
addTearDown(gesture.removePointer); | ||
await tester.pump(); | ||
await gesture.moveTo(tester.getCenter(find.byType(PathChips))); | ||
await tester.pumpAndSettle(); | ||
|
||
expect( | ||
find.byWidgetPredicate((Widget widget) => | ||
widget is Container && widget.color == Colors.grey[170]), | ||
findsOneWidget); | ||
}); | ||
} |