|
| 1 | +<?php |
| 2 | + |
| 3 | +beforeEach(function () { |
| 4 | + $this->app->instance( |
| 5 | + \Cloudinary\Cloudinary::class, |
| 6 | + new \Cloudinary\Cloudinary('cloudinary://key:secret@demo') |
| 7 | + ); |
| 8 | +}); |
| 9 | + |
| 10 | +it('renders image component with both class and alt attributes', function () { |
| 11 | + $html = view('cloudinary::components.image', [ |
| 12 | + 'publicId' => 'example', |
| 13 | + 'class' => 'img-fluid', |
| 14 | + 'alt' => 'Parallax Background Image', |
| 15 | + ])->render(); |
| 16 | + |
| 17 | + expect($html)->toContain('class="img-fluid"'); |
| 18 | + expect($html)->toContain('alt="Parallax Background Image"'); |
| 19 | +}); |
| 20 | + |
| 21 | +it('includes crop, width and height transformation when provided', function () { |
| 22 | + $html = view('cloudinary::components.image', [ |
| 23 | + 'publicId' => 'example', |
| 24 | + 'crop' => 'fill', |
| 25 | + 'width' => 300, |
| 26 | + 'height' => 200, |
| 27 | + ])->render(); |
| 28 | + |
| 29 | + expect($html)->toContain('w_'); |
| 30 | + expect($html)->toContain('h_'); |
| 31 | + expect($html)->toContain('c_'); |
| 32 | +}); |
| 33 | + |
| 34 | +it('includes rotation when rotate attribute is provided', function () { |
| 35 | + $html = view('cloudinary::components.image', [ |
| 36 | + 'publicId' => 'example', |
| 37 | + 'rotate' => 90, |
| 38 | + ])->render(); |
| 39 | + |
| 40 | + expect($html)->toContain('a_'); |
| 41 | +}); |
| 42 | + |
| 43 | +it('applies grayscale effect when requested', function () { |
| 44 | + $html = view('cloudinary::components.image', [ |
| 45 | + 'publicId' => 'example', |
| 46 | + 'grayscale' => true, |
| 47 | + ])->render(); |
| 48 | + |
| 49 | + expect($html)->toContain('e_grayscale'); |
| 50 | +}); |
| 51 | + |
| 52 | +it('applies round corners when requested', function () { |
| 53 | + $html = view('cloudinary::components.image', [ |
| 54 | + 'publicId' => 'example', |
| 55 | + 'roundCorners' => true, |
| 56 | + ])->render(); |
| 57 | + |
| 58 | + expect($html)->toContain('r_'); |
| 59 | +}); |
| 60 | + |
| 61 | +it('preserves multiple classes when provided', function () { |
| 62 | + $html = view('cloudinary::components.image', [ |
| 63 | + 'publicId' => 'example', |
| 64 | + 'class' => 'img-fluid rounded mx-auto', |
| 65 | + ])->render(); |
| 66 | + |
| 67 | + expect($html)->toContain('class="img-fluid rounded mx-auto"'); |
| 68 | +}); |
0 commit comments