Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Sep 30, 2018
1 parent 55155b1 commit dfa6741
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
35 changes: 19 additions & 16 deletions tests/BladeXTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,15 @@ public function it_compiles_a_regular_component()
{
BladeX::component('components.card');

$this->assertMatchesXmlSnapshot(
view('views.regularComponent')->render()
);
$this->assertMatchesViewSnapshot('regularComponent');
}

/** @test */
public function it_compiles_a_self_closing_component()
{
BladeX::component('components.alert');

$this->assertMatchesXmlSnapshot(
view('views.selfClosingComponent')->render()
);
$this->assertMatchesViewSnapshot('selfClosingComponent');
}

/** @test */
Expand All @@ -91,29 +87,31 @@ public function it_compiles_a_view_with_two_components()
BladeX::component('components.card');
BladeX::component('components.textField');

$this->assertMatchesXmlSnapshot(
view('views.twoComponents')->render()
);
$this->assertMatchesViewSnapshot('twoComponents');
}

/** @test */
public function it_compiles_a_component_that_contains_nested_components()
{
BladeX::component('components.card');

$this->assertMatchesViewSnapshot('nestedComponents');
}

/** @test */
public function it_compiles_a_component_with_scoped_slots()
{
BladeX::component('components.layout');

$this->assertMatchesXmlSnapshot(
view('views.componentWithScopedSlots')->render()
);
$this->assertMatchesViewSnapshot('componentWithScopedSlots');
}

/** @test */
public function it_compiles_a_component_with_variables()
{
BladeX::component('components.card');

$this->assertMatchesXmlSnapshot(
view('views.componentWithVariables')->render()
);
$this->assertMatchesViewSnapshot('componentWithVariables');
}

/** @test */
Expand All @@ -123,8 +121,13 @@ public function it_works_with_a_global_prefix()

BladeX::prefix('x');

$this->assertMatchesViewSnapshot('globalPrefix');
}

protected function assertMatchesViewSnapshot(string $viewName)
{
$this->assertMatchesXmlSnapshot(
view('views.globalPrefix')->render()
view("views.{$viewName}")->render()
);
}
}
7 changes: 7 additions & 0 deletions tests/stubs/views/views/nestedComponents.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<card title="Title">
<card title="Subtitle">
<card title="Subsubtitle">
Inner card
</card>
</card>
</card>

0 comments on commit dfa6741

Please sign in to comment.