From 246e281d68fadc676fdbd5cc2ba01115b3777162 Mon Sep 17 00:00:00 2001 From: Dennis Eilander Date: Tue, 21 Jan 2025 17:32:49 +0100 Subject: [PATCH] [9] Add AboutApplicationTest --- tests/AboutApplicationTest.php | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/AboutApplicationTest.php diff --git a/tests/AboutApplicationTest.php b/tests/AboutApplicationTest.php new file mode 100644 index 0000000..1970a6b --- /dev/null +++ b/tests/AboutApplicationTest.php @@ -0,0 +1,53 @@ + [ + 'filled' => 'foo', + 'empty_string' => '', + ], + 'booleans' => [ + 'true_value' => true, + 'false_value' => false, + ], + 'numbers' => [ + 'integer' => 12345, + 'float' => 123.45, + ], + 'arrays' => [ + 'simple_array' => ['one', 'two', 'three'], + 'empty_array' => [], + ], + 'nullables' => [ + 'null_value' => null, + 'empty_string' => '', + ], + ]); + + // Simulate the configuration for categories to hide. + config(['pulse-about-application.hide' => ['nullables']]); + + $formatted = AboutApplication::formatInformation($information); + + // Assert the structure and transformations. + expect($formatted)->toBeInstanceOf(Collection::class); + + // Ensure hidden categories are removed. + expect($formatted->has('nullables'))->toBeFalse(); + + // Validate transformations. + expect($formatted['strings']['filled'])->toBe('foo'); + expect($formatted['strings']['empty_string'])->toBe('-'); + + expect($formatted['booleans']['true_value'])->toBe('Yes'); + expect($formatted['booleans']['false_value'])->toBe('No'); + + expect($formatted['numbers']['integer'])->toBe('12,345'); + expect($formatted['numbers']['float'])->toBe('123.45'); + + expect($formatted['arrays']['simple_array'])->toBe('one, two, three'); + expect($formatted['arrays']['empty_array'])->toBe(''); +});