-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathMobilePricingTest.php
More file actions
71 lines (61 loc) · 2.26 KB
/
MobilePricingTest.php
File metadata and controls
71 lines (61 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Tests\Feature;
use App\Livewire\MobilePricing;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Auth;
use Livewire\Livewire;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class MobilePricingTest extends TestCase
{
use RefreshDatabase;
#[Test]
public function authenticated_users_will_directly_create_checkout_session()
{
$user = User::factory()->create();
Auth::login($user);
$component = Livewire::test(MobilePricing::class);
$component->assertSeeHtml([
'wire:click="createCheckoutSession(\'mini\')"',
'wire:click="createCheckoutSession(\'pro\')"',
'wire:click="createCheckoutSession(\'max\')"',
]);
$component->assertDontSeeHtml([
'@click="$dispatch(\'open-purchase-modal\', { plan: \'mini\' })"',
'@click="$dispatch(\'open-purchase-modal\', { plan: \'pro\' })"',
'@click="$dispatch(\'open-purchase-modal\', { plan: \'max\' })"',
]);
}
#[Test]
public function guest_users_see_purchase_modal_component()
{
Auth::logout();
Livewire::test(MobilePricing::class)
->assertSeeLivewire('purchase-modal')
->assertSeeHtml([
'@click="$dispatch(\'open-purchase-modal\', { plan: \'mini\' })"',
'@click="$dispatch(\'open-purchase-modal\', { plan: \'pro\' })"',
'@click="$dispatch(\'open-purchase-modal\', { plan: \'max\' })"',
])
->assertDontSeeHtml([
'wire:click="createCheckoutSession(\'mini\')"',
'wire:click="createCheckoutSession(\'pro\')"',
'wire:click="createCheckoutSession(\'max\')"',
]);
}
#[Test]
public function authenticated_users_do_not_see_purchase_modal_component()
{
Auth::login(User::factory()->create());
Livewire::test(MobilePricing::class)
->assertDontSeeLivewire('purchase-modal');
}
#[Test]
public function it_validates_email_before_creating_user()
{
Livewire::test(MobilePricing::class)
->call('handlePurchaseRequest', ['email' => 'invalid-email'])
->assertHasErrors('email');
}
}