toBeInstanceOf(ProductWeight::class) ->and($vo->value)->toBe(1600) ->and($vo->toGrams())->toBe(1600); }); it('throws exception if weight is less than 1', function () { // GIVEN // WHEN $action = fn () => new ProductWeight(0, false); // THEN expect($action)->toThrow(\DomainException::class); }); it('formats weight in grams when under 1000', function () { // GIVEN $vo = new ProductWeight(250, false); // WHEN $result = $vo->forDisplay(); // THEN expect($result)->toBe('250 g'); }); it('formats weight in kg when 1000 or more', function () { // GIVEN $vo = new ProductWeight(1600, false); // WHEN $result = $vo->forDisplay(); // THEN expect($result)->toBe('1,6 kg'); }); it('formats weight as integer kg when no decimal part', function () { // GIVEN $vo = new ProductWeight(12000, false); // WHEN $result = $vo->forDisplay(); // THEN expect($result)->toBe('12 kg'); }); it('formats weight correctly for exactly 1 kg', function () { // GIVEN $vo = new ProductWeight(1000, false); // WHEN $result = $vo->forDisplay(); // THEN expect($result)->toBe('1 kg'); }); });