Skip to content

Commit

Permalink
Add test for image with a link
Browse files Browse the repository at this point in the history
  • Loading branch information
levimykel committed Oct 17, 2017
1 parent 66f0728 commit 25575ed
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Prismic/StructuredTextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ public function testWebLinkRenderingTargetBlank()
$this->assertEquals($document->getStructuredText('product.description')->asHtml(), '<p>Link that <a target="_blank" rel="noopener" href="https://prismic.io">opens in a new tab</a>.</p>');
}

public function testImageRenderingTargetBlank()
{
$weblinks = json_decode(file_get_contents(__DIR__.'/../fixtures/weblinks_targetblank.json'));
$document = Document::parse($weblinks);
$this->assertEquals($document->getStructuredText('product.image_with_link')->asHtml(), '<p class="block-img"><a target="_blank" rel="noopener" href="https://prismic.io"><img src="https://prismic-io.s3.amazonaws.com/serializer-example/aa4f6471fd8b920e92914146a4688154a2d727d6_daria-nepriakhina-1277.jpg" alt="" width="500" height="200"></a></p>');
}

public function testStructuredTextHtmlHasBreakTags()
{
$this->assertRegExp('`can be rough sometimes\.\s*<br\s*/?>\s*This is after a new line\.`s', $this->structuredText->asHtml());
Expand Down
22 changes: 22 additions & 0 deletions tests/fixtures/weblinks_targetblank.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@
}
]
},
"image_with_link": {
"type": "StructuredText",
"value": [
{
"type": "image",
"url": "https://prismic-io.s3.amazonaws.com/serializer-example/aa4f6471fd8b920e92914146a4688154a2d727d6_daria-nepriakhina-1277.jpg",
"alt": null,
"copyright": null,
"dimensions": {
"width": 500,
"height": 200
},
"linkTo": {
"type": "Link.web",
"value": {
"url": "https://prismic.io",
"target": "_blank"
}
}
}
]
},
"link": {
"type": "Link.web",
"value": {
Expand Down

0 comments on commit 25575ed

Please sign in to comment.