-
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
2 changed files
with
53 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:swc_flutter/src/provider_helper.dart'; | ||
|
||
void main() { | ||
group("Test ProviderHelper", () { | ||
testWidgets("pGet should return content", (tester) async { | ||
final content = "Hi!"; | ||
await tester.pumpWidget(MaterialApp( | ||
home: _PGetTestWidget(content: content), | ||
)); | ||
expect(find.text(content), findsOneWidget); | ||
}); | ||
|
||
testWidgets("pGet should return null", (tester) async { | ||
await tester.pumpWidget(MaterialApp( | ||
home: _PGetTestWidget(), | ||
)); | ||
expect(find.text("null"), findsOneWidget); | ||
}); | ||
}); | ||
} | ||
|
||
class _PGetTestWidget extends StatelessWidget with ProviderHelper { | ||
|
||
final String content; | ||
|
||
_PGetTestWidget({this.content}); | ||
|
||
Widget build(BuildContext context) { | ||
return Provider<String>( | ||
create: (_) => content, | ||
child: Builder(builder: (context) { | ||
return Text(pGet<String>(context).toString()); | ||
}), | ||
); | ||
} | ||
|
||
} | ||
|
||
class _InvalidPGetTestWidget extends StatelessWidget with ProviderHelper { | ||
|
||
Widget build(BuildContext context) { | ||
return Text(pGet<String>(context).toString()); | ||
} | ||
|
||
} |
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