From 841565368591cf7de32c828290b3d37b9ab96761 Mon Sep 17 00:00:00 2001 From: YannickFricke Date: Sun, 17 Nov 2024 13:31:22 +0100 Subject: [PATCH] test(logger): added test for checking the log level The logger should not print anything to the console when the LogLevel is higher than the needed one. --- packages/ying-shared/test/logging/logger_test.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/ying-shared/test/logging/logger_test.dart b/packages/ying-shared/test/logging/logger_test.dart index ebcd9f2..6163f2e 100644 --- a/packages/ying-shared/test/logging/logger_test.dart +++ b/packages/ying-shared/test/logging/logger_test.dart @@ -96,5 +96,18 @@ void main() { }, prints("[01.01.2024] [00:00:00.00] [TRACE] [unit] unit-test\n")); }); }); + + test('it should not print anything when the LogLevel is too low', () { + withClock(Clock.fixed(DateTime(2024)), () { + expect(() { + final logger = Logger.withSimpleName("unit", LogLevel.info); + + logger.trace("unit-test"); + }, + isNot( + prints("[01.01.2024] [00:00:00.00] [TRACE] [unit] unit-test\n"), + )); + }); + }); }); }