Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add phpunit tests
  • Loading branch information
Dion Potkamp committed Jun 16, 2021
commit 1aea8b0b61c6fc73eaa4feffa8b2670797cf020a
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<span {!! $attributes->merge(['class' => 'input-group-text']) !!}>{{ $text }}</span>
<span {!! $attributes->merge(['class' => 'input-group-text']) !!}>{!! $slot !!}</span>
35 changes: 35 additions & 0 deletions tests/Feature/Bootstrap4Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace ProtoneMedia\LaravelFormComponents\Tests\Feature;

use ProtoneMedia\LaravelFormComponents\Tests\TestCase;

class Bootstrap4Test extends TestCase
{
public function setUp(): void
{
parent::setUp();

if (config('form-components.framework') !== 'bootstrap-4') {
$this->markTestSkipped('Other framework configured');
}
}

/** @test */
public function it_can_append_to_an_input()
{
$this->registerTestRoute('bootstrap-append');

$this->visit('/bootstrap-append')
->seeInElement('.input-group-text', '.protone.media');
}

/** @test */
public function it_can_prepend_to_an_input()
{
$this->registerTestRoute('bootstrap-prepend');

$this->visit('/bootstrap-prepend')
->seeInElement('.input-group-text', 'info@');
}
}
42 changes: 42 additions & 0 deletions tests/Feature/Bootstrap5Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace ProtoneMedia\LaravelFormComponents\Tests\Feature;

use ProtoneMedia\LaravelFormComponents\Tests\TestCase;

class Bootstrap5Test extends TestCase
{
public function setUp(): void
{
parent::setUp();

if (config('form-components.framework') !== 'bootstrap-5') {
$this->markTestSkipped('Other framework configured');
}
}

/** @test */
public function it_can_group_elements()
{
$this->registerTestRoute('bootstrap-input-group');

$this->visit('/bootstrap-input-group')
->within('.input-group', function() {
return $this->seeElementCount('.form-control', 2)
->seeElementCount('.input-group-text', 1)
->seeInElement('.input-group-text', '@');
});
}

/** @test */
public function it_can_float_labels()
{
$this->registerTestRoute('bootstrap-floating-label');

$this->visit('/bootstrap-floating-label')
->seeElementCount('label', 2)
->seeInElement('label', 'Your Name')
->seeElement('#name1', ['placeholder' => ' '])
->seeElement('#name2', ['placeholder' => 'John Doe']);
}
}
20 changes: 1 addition & 19 deletions tests/Feature/BootstrapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,11 @@ public function setUp(): void
{
parent::setUp();

if (config('form-components.framework') !== 'bootstrap-4') {
if (!in_array(config('form-components.framework'), ['bootstrap-4', 'bootstrap-5'])) {
$this->markTestSkipped('Other framework configured');
}
}

/** @test */
public function it_can_append_to_an_input()
{
$this->registerTestRoute('bootstrap-append');

$this->visit('/bootstrap-append')
->seeInElement('.input-group-text', '.protone.media');
}

/** @test */
public function it_can_prepend_to_an_input()
{
$this->registerTestRoute('bootstrap-prepend');

$this->visit('/bootstrap-prepend')
->seeInElement('.input-group-text', 'info@');
}

/** @test */
public function it_can_add_help_text()
{
Expand Down
4 changes: 4 additions & 0 deletions tests/Feature/views/bootstrap-floating-label.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<x-form>
<x-form-input floating name="name" id="name1" label="Your Name" />
<x-form-input floating name="name" id="name2" label="Your Name" placeholder="John Doe" />
</x-form>
7 changes: 7 additions & 0 deletions tests/Feature/views/bootstrap-input-group.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<x-form>
<x-form-input-group>
<x-form-input name="name" id="name" />
<x-form-input-group-text>@</x-form-input-group-text>
<x-form-input name="username" id="username"></x-form-input>
</x-form-input-group>
</x-form>