Files
hans 0078e344fd v2.0.6: Remove export of Error and Ok from result_monad (#12)
* Update Logging feature to replace @LoggingFeature annotation with LoggerName mixin for runtime accessibility

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

* Bump version to 2.0.2 in pubspec.yaml and update CHANGELOG to reflect the new version

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

* Add migration steps for replacing @LoggingFeature annotation with LoggerName mixin in CHANGELOG

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

* Fix class declaration in migration example for LoggerName mixin

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

* Enhance CI workflow, coverage enforcement, and environment tests (#10)

* Enhance CI workflow and coverage enforcement; update tests and add new environment tests

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

* Revert version bump in pubspec.yaml and remove test coverage note from CHANGELOG

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

* Update test to expect a thrown exception when no interfaces are registered

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

* Add ArcaneEnvironmentModeController and related tests for debug mode management

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

* Refactor theme switcher tests to use platform dispatcher for brightness change simulation

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

---------

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>

* refactor(api): Remove export of Error and Ok from result_monad (#11)

The `Error` and `Ok` symbols from the `result_monad` package are no longer
re-exported directly by `arcane_framework`. Consumers needing these
symbols must now explicitly import them from `package:result_monad`.
This clarifies dependency ownership and reduces `arcane_framework`'s
public API surface.

---------

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-06-19 20:28:24 +02:00

108 lines
2.8 KiB
Dart

import "package:arcane_framework/arcane_framework.dart";
import "package:flutter_test/flutter_test.dart";
void main() {
group("ArcaneEnvironmentService", () {
late ArcaneEnvironmentService service;
setUp(() {
service = ArcaneEnvironmentService.I;
service.reset();
});
test("singleton instance is consistent", () {
expect(identical(ArcaneEnvironmentService.I, service), isTrue);
expect(identical(Arcane.environment, service), isTrue);
});
test("default environment is normal", () {
expect(service.current, Environment.normal);
});
test("setEnvironment updates current value", () {
service.setEnvironment(Environment.debug);
expect(service.current, Environment.debug);
});
test("setEnvironment with same value does not emit stream event", () async {
var didEmit = false;
final sub = service.environmentChanges.listen((_) {
didEmit = true;
});
service.setEnvironment(Environment.normal);
await Future<void>.delayed(Duration.zero);
expect(didEmit, isFalse);
await sub.cancel();
});
test("setEnvironment with different value emits stream event", () async {
final event = expectLater(
service.environmentChanges,
emits(Environment.debug),
);
service.setEnvironment(Environment.debug);
await event;
});
test("notifier listeners are notified on changes", () {
var notified = false;
service.notifier.addListener(() {
notified = true;
});
service.setEnvironment(Environment.debug);
expect(notified, isTrue);
});
test("enableDebugMode and disableDebugMode switch built-in modes", () {
service.enableDebugMode();
expect(service.current, Environment.debug);
service.disableDebugMode();
expect(service.current, Environment.normal);
});
test("reset restores normal and emits current state", () async {
service.setEnvironment(Environment.debug);
final event = expectLater(
service.environmentChanges,
emits(Environment.normal),
);
service.reset();
expect(service.current, Environment.normal);
await event;
});
test("environmentChanges works after listener cancellation", () async {
final first = service.environmentChanges.listen((_) {});
await first.cancel();
final event = expectLater(
service.environmentChanges,
emits(Environment.debug),
);
service.setEnvironment(Environment.debug);
await event;
});
test("dispose closes stream and subsequent reads recreate it", () async {
service.dispose();
final event = expectLater(
service.environmentChanges,
emits(Environment.debug),
);
service.setEnvironment(Environment.debug);
await event;
});
});
}