Skip to content

Commit bedb0a8

Browse files
committed
Create unit test flavor_config_test.dart
1 parent 0b70561 commit bedb0a8

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import 'package:flutter_news_app/config/flavor_config.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
4+
void main() {
5+
const tBaseUrlNewsEndpoint = 'testBaseUrlNewsEndpoint';
6+
final values = FlavorValues(
7+
baseUrlNewsEndpoint: tBaseUrlNewsEndpoint,
8+
);
9+
10+
test(
11+
'Should return true while call the function isProduction with flavor production',
12+
() async {
13+
// arrange
14+
FlavorConfig(
15+
flavor: Flavor.production,
16+
values: values,
17+
);
18+
19+
// act
20+
final result = FlavorConfig.isProduction();
21+
22+
// assert
23+
expect(result, true);
24+
},
25+
);
26+
27+
test(
28+
'Should return false while call the function isProduction with flavor development',
29+
() async {
30+
// arrange
31+
FlavorConfig(
32+
flavor: Flavor.development,
33+
values: values,
34+
);
35+
36+
// act
37+
final result = FlavorConfig.isProduction();
38+
39+
// assert
40+
expect(result, false);
41+
},
42+
);
43+
44+
test(
45+
'Should return false while call the function isDevelopment with flavor production',
46+
() async {
47+
// arrange
48+
FlavorConfig(
49+
flavor: Flavor.production,
50+
values: values,
51+
);
52+
53+
// act
54+
final result = FlavorConfig.isDevelopment();
55+
56+
// assert
57+
expect(result, false);
58+
},
59+
);
60+
61+
test(
62+
'Should return true while call the function isProduction with flavor development',
63+
() async {
64+
// arrange
65+
FlavorConfig(
66+
flavor: Flavor.development,
67+
values: values,
68+
);
69+
70+
// act
71+
final result = FlavorConfig.isDevelopment();
72+
73+
// assert
74+
expect(result, true);
75+
},
76+
);
77+
}

0 commit comments

Comments
 (0)