mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Add Status Lexer Test
This commit is contained in:
parent
54f996b853
commit
127990e95f
1 changed files with 66 additions and 0 deletions
66
tests/Unit/Lexer/StatusLexerTest.php
Normal file
66
tests/Unit/Lexer/StatusLexerTest.php
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit\Lexer;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use App\Util\Lexer\Autolink;
|
||||||
|
use App\Util\Lexer\Extractor;
|
||||||
|
|
||||||
|
class StatusLexerTest extends TestCase
|
||||||
|
{
|
||||||
|
public $status;
|
||||||
|
public $entities;
|
||||||
|
public $autolink;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->status = "@pixelfed hi, really like the website! #píxelfed";
|
||||||
|
$this->entities = Extractor::create()->extract($this->status);
|
||||||
|
$this->autolink = Autolink::create()->autolink($this->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLexerExtractor()
|
||||||
|
{
|
||||||
|
$expected = [
|
||||||
|
"hashtags" => [
|
||||||
|
"píxelfed",
|
||||||
|
],
|
||||||
|
"urls" => [],
|
||||||
|
"mentions" => [
|
||||||
|
"pixelfed",
|
||||||
|
],
|
||||||
|
"replyto" => "pixelfed",
|
||||||
|
"hashtags_with_indices" => [
|
||||||
|
[
|
||||||
|
"hashtag" => "píxelfed",
|
||||||
|
"indices" => [
|
||||||
|
39,
|
||||||
|
48,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
"urls_with_indices" => [],
|
||||||
|
"mentions_with_indices" => [
|
||||||
|
[
|
||||||
|
"screen_name" => "pixelfed",
|
||||||
|
"indices" => [
|
||||||
|
0,
|
||||||
|
9,
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->assertEquals($this->entities, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAutolink()
|
||||||
|
{
|
||||||
|
$expected = '@<a class="u-url mention" href="https://pixelfed.dev/pixelfed" rel="external nofollow noopener" target="_blank">pixelfed</a> hi, really like the website! <a href="https://pixelfed.dev/discover/tags/píxelfed?src=hash" title="#píxelfed" class="u-url hashtag" rel="external nofollow noopener">#píxelfed</a>';
|
||||||
|
|
||||||
|
$this->assertEquals($this->autolink, $expected);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue