|
173 | 173 |
|
174 | 174 | expect($result)->toBe('some text replaced text dewde');
|
175 | 175 | });
|
| 176 | + |
| 177 | + describe('urlFriendlyOutput', function () { |
| 178 | + test('it encodes special characters in values', function () { |
| 179 | + $content = '<p>Test: <span mention mention-field-id="123">Placeholder</span></p>'; |
| 180 | + $data = [['id' => '123', 'value' => 'Hello & World']]; |
| 181 | + |
| 182 | + $parser = new MentionParser($content, $data); |
| 183 | + $result = $parser->urlFriendlyOutput()->parse(); |
| 184 | + |
| 185 | + expect($result)->toBe('<p>Test: Hello+%26+World</p>'); |
| 186 | + }); |
| 187 | + |
| 188 | + test('it encodes spaces in values', function () { |
| 189 | + $content = '<p>Name: <span mention mention-field-id="123">Placeholder</span></p>'; |
| 190 | + $data = [['id' => '123', 'value' => 'John Doe']]; |
| 191 | + |
| 192 | + $parser = new MentionParser($content, $data); |
| 193 | + $result = $parser->urlFriendlyOutput()->parse(); |
| 194 | + |
| 195 | + expect($result)->toBe('<p>Name: John+Doe</p>'); |
| 196 | + }); |
| 197 | + |
| 198 | + test('it encodes array values', function () { |
| 199 | + $content = '<p>Tags: <span mention mention-field-id="123">Placeholder</span></p>'; |
| 200 | + $data = [['id' => '123', 'value' => ['Web & Mobile', 'PHP/Laravel']]]; |
| 201 | + |
| 202 | + $parser = new MentionParser($content, $data); |
| 203 | + $result = $parser->urlFriendlyOutput()->parse(); |
| 204 | + |
| 205 | + expect($result)->toBe('<p>Tags: Web+%26+Mobile,+PHP%2FLaravel</p>'); |
| 206 | + }); |
| 207 | + |
| 208 | + test('it can be disabled explicitly', function () { |
| 209 | + $content = '<p>Test: <span mention mention-field-id="123">Placeholder</span></p>'; |
| 210 | + $data = [['id' => '123', 'value' => 'Hello & World']]; |
| 211 | + |
| 212 | + $parser = new MentionParser($content, $data); |
| 213 | + $result = $parser->urlFriendlyOutput(false)->parse(); |
| 214 | + |
| 215 | + expect($result)->toBe('<p>Test: Hello & World</p>'); |
| 216 | + }); |
| 217 | + }); |
176 | 218 | });
|
0 commit comments