Set aria-hidden attribute depending on whether a title has been passed in or not
This commit is contained in:
@@ -280,4 +280,23 @@ class IconRuntimeTest extends TestCase
|
||||
$this->assertStringNotContainsString($needleA, $contents);
|
||||
$this->assertStringNotContainsString($needleB, $contents);
|
||||
}
|
||||
|
||||
public function testAriaHiddenAttributeIsAdded(): void
|
||||
{
|
||||
$contents = $this->icon->renderIcon(['icon' => self::ICON]);
|
||||
$this->assertMatchesRegularExpression('/<svg.+aria-hidden="true".*>/', $contents);
|
||||
}
|
||||
|
||||
public function testAriaHiddenAttributeIsSetToTrueIfAlreadyPresent(): void
|
||||
{
|
||||
$contents = $this->icon->renderIcon(['icon' => 'attr']);
|
||||
$this->assertMatchesRegularExpression('/<svg.+aria-hidden="true".*>/', $contents);
|
||||
$this->assertDoesNotMatchRegularExpression('/<svg.+aria-hidden="false".*>/', $contents);
|
||||
}
|
||||
|
||||
public function testAriaHiddenAttributeIsSetToFalseIfATitleIsPassedIn(): void
|
||||
{
|
||||
$contents = $this->icon->renderIcon(['icon' => self::ICON, 'title' => 'something']);
|
||||
$this->assertMatchesRegularExpression('/<svg.+aria-hidden="false".*>/', $contents);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user