-
Notifications
You must be signed in to change notification settings - Fork 26
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
8 changed files
with
109 additions
and
17 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
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 |
---|---|---|
@@ -1 +1,7 @@ | ||
enum AppTheme { light, dark, yellow, system, experimental } | ||
enum AppTheme { | ||
light, | ||
dark, | ||
yellow, | ||
system, | ||
experimental, | ||
} |
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 |
---|---|---|
@@ -1,6 +1,14 @@ | ||
/// Represents different build types for the application. | ||
enum BuildType { | ||
/// The debug build type is used during development for debugging purposes. | ||
debug, | ||
|
||
/// The staging build type is used for testing in a staging environment. | ||
staging, | ||
|
||
/// The QA build type is used for quality assurance testing. | ||
qa, | ||
|
||
/// The release build type is the final production build. | ||
release, | ||
} |
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
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
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
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
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,59 @@ | ||
import 'package:flutter_bloc_app_template/config/build_type.dart'; | ||
import 'package:flutter_bloc_app_template/config/environment.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('Environment Tests', () { | ||
test('Initialization and Properties', () { | ||
Environment.init( | ||
buildType: BuildType.debug, | ||
config: 'Debug Config', | ||
); | ||
|
||
final environment = Environment<String>.instance(); | ||
|
||
expect(environment.config, 'Debug Config'); | ||
expect(environment.isDebug, true); | ||
expect(environment.isRelease, false); | ||
expect(environment.buildType, BuildType.debug); | ||
}); | ||
|
||
test('Config Update', () { | ||
Environment.init( | ||
buildType: BuildType.debug, | ||
config: 'Initial Config', | ||
); | ||
|
||
final environment = Environment<String>.instance() | ||
..config = 'Updated Config'; | ||
|
||
expect(environment.config, 'Updated Config'); | ||
}); | ||
|
||
test('Listener Notification', () { | ||
Environment.init( | ||
buildType: BuildType.debug, | ||
config: 'Debug Config', | ||
); | ||
|
||
final environment = Environment<String>.instance(); | ||
|
||
var listenerCallCount = 0; | ||
void listenerCallback() { | ||
listenerCallCount++; | ||
} | ||
|
||
environment..addListener(listenerCallback) | ||
..config = 'Updated Config'; | ||
|
||
// Ensure that the listener has been notified | ||
expect(listenerCallCount, 1); | ||
|
||
environment..removeListener(listenerCallback) | ||
..config = 'Another Update'; | ||
|
||
// Listener should not be called after removal | ||
expect(listenerCallCount, 1); | ||
}); | ||
}); | ||
} |