|
2 | 2 |
|
3 | 3 | use SweetAlert2\Laravel\Swal; |
4 | 4 |
|
5 | | -test('Swal::fire() should work', function () { |
| 5 | +test('Swal::fire()', function () { |
6 | 6 | Swal::fire([ |
7 | 7 | 'title' => 'SweetAlert2 + Laravel = <3', |
8 | 8 | 'text' => 'This is a simple alert using SweetAlert2', |
|
17 | 17 | ->assertSee("import Swal from 'https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.esm.all.min.js'", escape: false) |
18 | 18 | ->assertSee('Swal.fire({"title":"SweetAlert2 + Laravel = \u003C3","text":"This is a simple alert using SweetAlert2","icon":"success","confirmButtonText":"Cool"})', escape: false); |
19 | 19 | }); |
| 20 | + |
| 21 | +test('Swal::success()', function () { |
| 22 | + Swal::success([ |
| 23 | + 'title' => 'success title', |
| 24 | + ]); |
| 25 | + |
| 26 | + $response = $this->get('/'); |
| 27 | + |
| 28 | + $response |
| 29 | + ->assertStatus(200) |
| 30 | + ->assertSee('Swal.fire({"icon":"success","title":"success title"})', escape: false); |
| 31 | +}); |
| 32 | + |
| 33 | +test('Swal::error()', function () { |
| 34 | + Swal::error([ |
| 35 | + 'title' => 'error title', |
| 36 | + ]); |
| 37 | + |
| 38 | + $response = $this->get('/'); |
| 39 | + |
| 40 | + $response |
| 41 | + ->assertStatus(200) |
| 42 | + ->assertSee('Swal.fire({"icon":"error","title":"error title"})', escape: false); |
| 43 | +}); |
| 44 | + |
| 45 | +test('Swal::warning()', function () { |
| 46 | + Swal::warning([ |
| 47 | + 'title' => 'warning title', |
| 48 | + ]); |
| 49 | + |
| 50 | + $response = $this->get('/'); |
| 51 | + |
| 52 | + $response |
| 53 | + ->assertStatus(200) |
| 54 | + ->assertSee('Swal.fire({"icon":"warning","title":"warning title"})', escape: false); |
| 55 | +}); |
| 56 | + |
| 57 | +test('Swal::info()', function () { |
| 58 | + Swal::info([ |
| 59 | + 'title' => 'info title', |
| 60 | + ]); |
| 61 | + |
| 62 | + $response = $this->get('/'); |
| 63 | + |
| 64 | + $response |
| 65 | + ->assertStatus(200) |
| 66 | + ->assertSee('Swal.fire({"icon":"info","title":"info title"})', escape: false); |
| 67 | +}); |
| 68 | + |
| 69 | +test('Swal::question()', function () { |
| 70 | + Swal::question([ |
| 71 | + 'title' => 'question title', |
| 72 | + ]); |
| 73 | + |
| 74 | + $response = $this->get('/'); |
| 75 | + |
| 76 | + $response |
| 77 | + ->assertStatus(200) |
| 78 | + ->assertSee('Swal.fire({"icon":"question","title":"question title"})', escape: false); |
| 79 | +}); |
| 80 | + |
| 81 | +test('Swal::toast()', function () { |
| 82 | + Swal::toast([ |
| 83 | + 'title' => 'toast title', |
| 84 | + ]); |
| 85 | + |
| 86 | + $response = $this->get('/'); |
| 87 | + |
| 88 | + $response |
| 89 | + ->assertStatus(200) |
| 90 | + ->assertSee('Swal.fire({"toast":true,"title":"toast title"})', escape: false); |
| 91 | +}); |
0 commit comments