Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jan 14, 2025
1 parent 18a46a4 commit ec45f80
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/Table/Column/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class LinkTest extends TestCase
use CreateAppTrait;
use TableTestTrait;

private const NBSP = "\u{00a0}";

/** @var Table */
protected $table;

Expand All @@ -26,14 +28,14 @@ protected function setUp(): void

$arr = [
'table' => [
1 => ['id' => 1, 'name' => 'bar', 'ref' => 'ref123', 'salary' => -123],
1 => ['id' => 1, 'name' => 'bar', 'ref' => 'ref123', 'salary' => -1234],
],
];
$db = new Persistence\Array_($arr);
$m = new Model($db, ['table' => 'table']);
$m->addField('name');
$m->addField('ref');
$m->addField('salary');
$m->addField('salary', ['type' => 'integer']);
$this->table = new Table();
$this->table->setApp($this->createApp());
$this->table->invokeInit();
Expand Down Expand Up @@ -72,7 +74,7 @@ public function testTdLast(): void
);

self::assertSame(
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="right aligned single line negative">-123</td></tr>',
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="right aligned single line negative">-1' . self::NBSP . '234</td></tr>',
$this->extractTableRow($this->table)
);
}
Expand All @@ -88,7 +90,7 @@ public function testTdNotLast(): void
);

self::assertSame(
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="right aligned single line negative"><b>-123</b></td></tr>',
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="right aligned single line negative"><b>-1' . self::NBSP . '234</b></td></tr>',
$this->extractTableRow($this->table)
);
}
Expand All @@ -105,7 +107,7 @@ public function testTwoMoneys(): void
);

self::assertSame(
'<tr data-id="1"><td class="right aligned single line ">bar</td><td>ref123</td><td class="right aligned single line negative"><b>-123</b></td></tr>',
'<tr data-id="1"><td class="right aligned single line ">bar</td><td>ref123</td><td class="right aligned single line negative"><b>-1' . self::NBSP . '234</b></td></tr>',
$this->extractTableRow($this->table)
);
}
Expand Down Expand Up @@ -278,10 +280,10 @@ public function testNoValue(): void

public function testTooltip(): void
{
$this->table->addDecorator('name', [Table\Column\Tooltip::class, ['tooltipField' => 'ref']]);
$this->table->addDecorator('name', [Table\Column\Tooltip::class, ['tooltipField' => 'salary']]);

self::assertSame(
'<tr data-id="1"><td class=""> bar<span class="ui icon link " data-tooltip="ref123"><i class="ui icon info circle"></span></td><td>ref123</td></tr>',
'<tr data-id="1"><td class=""> bar<span class="ui icon link " data-tooltip="-1' . self::NBSP . '234"><i class="ui icon info circle"></span></td><td>ref123</td></tr>',
$this->extractTableRow($this->table)
);
}
Expand Down

0 comments on commit ec45f80

Please sign in to comment.