Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romalytvynenko committed Jun 28, 2024
1 parent f993cd4 commit 95a8695
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/ValidationRulesDocumentingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,34 @@
->toHaveKey('maximum', 8);
});

it('converts min rule into "minLength" for string fields', function () {
$rules = [
'str' => ['string', 'min:8'],
];

$params = app()->make(RulesToParameters::class, ['rules' => $rules])->handle();

expect($params = collect($params)->all())
->toHaveCount(1)
->and($params[0]->schema->type)
->toBeInstanceOf(\Dedoc\Scramble\Support\Generator\Types\StringType::class)
->toHaveKey('minLength', 8);
});

it('converts max rule into "maxLength" for string fields', function () {
$rules = [
'str' => ['string', 'max:8'],
];

$params = app()->make(RulesToParameters::class, ['rules' => $rules])->handle();

expect($params = collect($params)->all())
->toHaveCount(1)
->and($params[0]->schema->type)
->toBeInstanceOf(\Dedoc\Scramble\Support\Generator\Types\StringType::class)
->toHaveKey('maxLength', 8);
});

it('converts min rule into "minItems" for array fields', function () {
$rules = [
'num' => ['array', 'min:8'],
Expand Down

0 comments on commit 95a8695

Please sign in to comment.