-
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
Showing
3 changed files
with
61 additions
and
5 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
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,56 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:tenor_flutter/src/components/components.dart'; | ||
import 'package:tenor_flutter/src/tools/debouncer.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:tenor_flutter/tenor_flutter.dart'; | ||
|
||
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('Category Widget >', () { | ||
testWidgets('If TenorCategory is null, find nothing', (tester) async { | ||
await tester.pumpWidget( | ||
const TenorCategoryWidget(), | ||
); | ||
|
||
expect(find.byType(GestureDetector), findsNothing); | ||
}); | ||
|
||
testWidgets('Make sure it renders and is tappable', (tester) async { | ||
// track if the tap was tapped | ||
bool hasTapped = false; | ||
|
||
// category to populate with | ||
final tenorCategoryTest = TenorCategory( | ||
name: 'test', | ||
searchTerm: 'test search term', | ||
path: 'path/to/category', | ||
image: 'https://flyclops.com/images/logo.png', | ||
); | ||
|
||
// display the category widget | ||
await tester.pumpWidget( | ||
Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: TenorCategoryWidget( | ||
category: tenorCategoryTest, | ||
onTap: (tenorCategory) { | ||
expect(tenorCategory, tenorCategoryTest); | ||
hasTapped = true; | ||
}, | ||
), | ||
), | ||
); | ||
|
||
// it should not have been tapped at this point | ||
expect(hasTapped, false); | ||
|
||
// tap it | ||
await tester.tap(find.byType(GestureDetector)); | ||
|
||
// make sure the tap went through | ||
expect(hasTapped, true); | ||
}); | ||
}); | ||
} |