Skip to content

Commit 414589d

Browse files
committed
Create unit test helper_test.dart
1 parent c8df22a commit 414589d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/core/util/helper_test.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import 'package:flutter_news_app/core/util/enum/top_headline_news_category.dart';
2+
import 'package:flutter_news_app/core/util/helper.dart';
3+
import 'package:flutter_test/flutter_test.dart';
4+
5+
void main() {
6+
final helper = Helper();
7+
8+
test(
9+
'Should return string of TopHeadlineNewsCategory',
10+
() async {
11+
// arrange
12+
const business = TopHeadlineNewsCategory.business;
13+
const entertainment = TopHeadlineNewsCategory.entertainment;
14+
const general = TopHeadlineNewsCategory.general;
15+
const health = TopHeadlineNewsCategory.health;
16+
const science = TopHeadlineNewsCategory.science;
17+
const sports = TopHeadlineNewsCategory.sports;
18+
const technology = TopHeadlineNewsCategory.technology;
19+
20+
// act
21+
final resultBusiness = helper.getStringTopHeadlineNewsCategory(business);
22+
final resultEntertainment = helper.getStringTopHeadlineNewsCategory(entertainment);
23+
final resultGeneral = helper.getStringTopHeadlineNewsCategory(general);
24+
final resultHealth = helper.getStringTopHeadlineNewsCategory(health);
25+
final resultScience = helper.getStringTopHeadlineNewsCategory(science);
26+
final resultSports = helper.getStringTopHeadlineNewsCategory(sports);
27+
final resultTechnology = helper.getStringTopHeadlineNewsCategory(technology);
28+
29+
// assert
30+
expect(resultBusiness, 'business');
31+
expect(resultEntertainment, 'entertainment');
32+
expect(resultGeneral, 'general');
33+
expect(resultHealth, 'health');
34+
expect(resultScience, 'science');
35+
expect(resultSports, 'sports');
36+
expect(resultTechnology, 'technology');
37+
},
38+
);
39+
}

0 commit comments

Comments
 (0)