Skip to content

Commit

Permalink
Merge pull request #8 from chrisrhymes/placeholder-tests
Browse files Browse the repository at this point in the history
Add placeholder tests
  • Loading branch information
chrisrhymes committed Jun 29, 2021
2 parents d602cf0 + 945e5ba commit 329ac4c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Components/HorizontalInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class HorizontalInputTest extends TestCase
{
use BaseInputComponentTests;
use ReadOnlyInputComponentTests;
use PlaceholderInputTests;

protected $component = 'horizontal-input';

Expand Down
1 change: 1 addition & 0 deletions tests/Components/HorizontalTextareaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class HorizontalTextareaTest extends TestCase
{
use BaseInputComponentTests;
use ReadOnlyInputComponentTests;
use PlaceholderInputTests;

protected $component = 'horizontal-input';
}
1 change: 1 addition & 0 deletions tests/Components/InputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class InputTest extends TestCase
{
use BaseInputComponentTests;
use ReadOnlyInputComponentTests;
use PlaceholderInputTests;

protected $component = 'input';

Expand Down
30 changes: 30 additions & 0 deletions tests/Components/PlaceholderInputTests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Tests\Components;

trait PlaceholderInputTests
{
/** @test */
public function inputs_render_without_placeholder()
{
$view = $this->withViewErrors([])
->blade(
'<x-bbui::'.$this->component.' :label="$label" :name="$name" :options="$options"></x-bbui::'.$this->component.'>',
['label' => 'The Input Label', 'name' => 'test', 'options' => ['first' => 'First option']]
);

$view->assertDontSee('placeholder');
}

/** @test */
public function inputs_render_placeholder_when_set()
{
$view = $this->withViewErrors([])
->blade(
'<x-bbui::'.$this->component.' :label="$label" :name="$name" :options="$options" :placeholder="$placeholder"></x-bbui::'.$this->component.'>',
['label' => 'The Input Label', 'name' => 'test', 'options' => ['first' => 'First option'], 'placeholder' => 'Enter some text']
);

$view->assertSee('placeholder="Enter some text"', false);
}
}
1 change: 1 addition & 0 deletions tests/Components/TextareaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TextareaTest extends TestCase
{
use BaseInputComponentTests;
use ReadOnlyInputComponentTests;
use PlaceholderInputTests;

protected $component = 'textarea';
}

0 comments on commit 329ac4c

Please sign in to comment.