-
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.
test(lock_item_icon_test.dart,thermostat_icon_test.dart,unknown_item_…
…icon_test.dart): Add basic green tests for lock, thermostat, and unknown icons
- Loading branch information
Showing
3 changed files
with
79 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:bootstrap_icons/bootstrap_icons.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/src/widgets/framework.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:yonomi_device_widgets/assets/traits/lock_item_icon.dart'; | ||
|
||
Widget createIconWidget(bool isLocked) { | ||
return MaterialApp( | ||
home: Scaffold(body: Container(child: LockIcon(isLocked))), | ||
); | ||
} | ||
|
||
void main() { | ||
testWidgets('should render correct Lock trait icon when unlocked', | ||
(WidgetTester tester) async { | ||
await tester.pumpWidget(createIconWidget(false)); | ||
expect(find.byIcon(BootstrapIcons.unlock), findsOneWidget); | ||
}); | ||
|
||
testWidgets('should render correct Lock trait icon when locked', | ||
(WidgetTester tester) async { | ||
await tester.pumpWidget(createIconWidget(true)); | ||
expect(find.byIcon(BootstrapIcons.lock), findsOneWidget); | ||
}); | ||
} |
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,33 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:yonomi_device_widgets/assets/traits/thermostat_icon.dart'; | ||
|
||
Widget createIconWidget( | ||
{double? thermostatState, Decoration? decoration, TextStyle? textStyle}) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
body: Container( | ||
child: ThermostatIcon( | ||
thermostatState: thermostatState, | ||
decoration: decoration, | ||
textStyle: textStyle, | ||
)), | ||
), | ||
); | ||
} | ||
|
||
void main() { | ||
testWidgets('should render correct thermostat trait icon', | ||
(WidgetTester tester) async { | ||
|
||
await tester.pumpWidget(createIconWidget(thermostatState: 22.1)); | ||
expect(find.widgetWithText(Center, '22'), findsOneWidget); | ||
}); | ||
|
||
testWidgets('should render n/a if target temperature is null', | ||
(WidgetTester tester) async { | ||
|
||
await tester.pumpWidget(createIconWidget()); | ||
expect(find.widgetWithText(Center, 'N/A'), findsOneWidget); | ||
}); | ||
} |
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,20 @@ | ||
import 'package:bootstrap_icons/bootstrap_icons.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/src/widgets/framework.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:yonomi_device_widgets/assets/traits/unknown_item_icon.dart'; | ||
import 'package:yonomi_platform_sdk/yonomi-sdk.dart'; | ||
|
||
Widget createIconWidget() { | ||
return MaterialApp( | ||
home: Scaffold(body: Container(child: UnknownItemIcon())), | ||
); | ||
} | ||
|
||
void main() { | ||
testWidgets('should render correct Unknown trait icon', | ||
(WidgetTester tester) async { | ||
await tester.pumpWidget(createIconWidget()); | ||
expect(find.byIcon(BootstrapIcons.box), findsOneWidget); | ||
}); | ||
} |