-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from viralkachhadiya/master
feat: Added unit test cases for helper classes
- Loading branch information
Showing
2 changed files
with
74 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,44 @@ | ||
import 'package:flutter_carplay/flutter_carplay.dart'; | ||
import 'package:flutter_carplay/helpers/carplay_helper.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('FlutterCarplayHelper', () { | ||
late FlutterCarplayHelper flutterCarplayHelper; | ||
|
||
final cpListItem=CPListItem(text: '<CPListItem>'); | ||
|
||
final cpListTemplate = CPListTemplate( | ||
title: '<CPListTemplate>', | ||
sections: [ | ||
CPListSection(items: [cpListItem]) | ||
], | ||
systemIcon: '<CarIcon>'); | ||
|
||
final templates = [ | ||
CPTabBarTemplate(title: '<CPTabBarTemplate>', templates: [cpListTemplate]), | ||
cpListTemplate | ||
]; | ||
|
||
setUp(() { | ||
flutterCarplayHelper = FlutterCarplayHelper(); | ||
}); | ||
|
||
test('find CPListItem from dynamic list item and element id', () { | ||
CPListItem? item = flutterCarplayHelper.findCPListItem(templates: templates, elementId: cpListItem.uniqueId); | ||
|
||
expect(item, cpListItem); | ||
|
||
CPListItem? nullableItem = flutterCarplayHelper.findCPListItem( | ||
templates: templates, elementId: ''); | ||
|
||
expect(nullableItem, null); | ||
}); | ||
|
||
test('make FCP channel id', () { | ||
String channelId = flutterCarplayHelper.makeFCPChannelId(event: '/event'); | ||
|
||
expect(channelId, 'com.oguzhnatly.flutter_carplay/event'); | ||
}); | ||
}); | ||
} |
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,30 @@ | ||
import 'package:flutter_carplay/flutter_carplay.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('CPEnumUtils', () { | ||
test('convert string into any type of enum', () { | ||
final cpListItemAccessoryType = | ||
CPEnumUtils.enumFromString(CPListItemAccessoryTypes.values, 'cloud'); | ||
|
||
expect(cpListItemAccessoryType, CPListItemAccessoryTypes.cloud); | ||
|
||
final cpListItemPlayingIndicatorLocation = CPEnumUtils.enumFromString( | ||
CPListItemPlayingIndicatorLocations.values, 'trailing'); | ||
|
||
expect(cpListItemPlayingIndicatorLocation, | ||
CPListItemPlayingIndicatorLocations.trailing); | ||
}); | ||
|
||
test('convert dynamic type into string after the `.`', () { | ||
final cpAlertActionStylesString = CPEnumUtils.stringFromEnum(CPAlertActionStyles.normal.toString()); | ||
|
||
expect(cpAlertActionStylesString, 'normal'); | ||
|
||
final fcpChannelTypesString = | ||
CPEnumUtils.stringFromEnum('car.setAlert'); | ||
|
||
expect(fcpChannelTypesString, 'setAlert'); | ||
}); | ||
}); | ||
} |