Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges-GNM committed Nov 12, 2024
1 parent dcf0cd4 commit 8f6753e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FaciaImageCutoutTest extends AnyFreeSpec with Matchers with TestContent {
"should return None for imageCutoutReplace=true but nothing to replace with" in {
val trailMeta = trailMetaDataWithImageCutout(true)
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMeta)
val imageCutout = FaciaImage.getFaciaImage(Some(emptyContent), trailMeta, resolvedMetaData)
val imageCutout = FaciaImage.getFaciaImage(Some(emptyContent), trailMeta, resolvedMetaData, None)
imageCutout should be (None)
}

Expand All @@ -48,13 +48,13 @@ class FaciaImageCutoutTest extends AnyFreeSpec with Matchers with TestContent {

val trailMetaTrue = trailMetaDataWithImageCutout(true, Option(src), width, height)
val resolvedMetaDataTrue = ResolvedMetaData.fromTrailMetaData(trailMetaTrue)
val imageCutoutTrue = FaciaImage.getFaciaImage(Some(emptyContent), trailMetaTrue, resolvedMetaDataTrue)
val imageCutoutTrue = FaciaImage.getFaciaImage(Some(emptyContent), trailMetaTrue, resolvedMetaDataTrue, None)
imageCutoutTrue.isDefined should be (true)
imageCutoutTrue should be (Some(Cutout(src, width, height)))

val trailMetaFalse = trailMetaDataWithImageCutout(false, Option(src), width, height)
val resolvedMetaDataFalse = ResolvedMetaData.fromTrailMetaData(trailMetaFalse)
val imageCutoutFalse = FaciaImage.getFaciaImage(Some(emptyContent), trailMetaFalse, resolvedMetaDataFalse)
val imageCutoutFalse = FaciaImage.getFaciaImage(Some(emptyContent), trailMetaFalse, resolvedMetaDataFalse, None)
imageCutoutFalse should be (None)
}

Expand All @@ -65,21 +65,21 @@ class FaciaImageCutoutTest extends AnyFreeSpec with Matchers with TestContent {

val trailMeta = trailMetaDataWithImageCutout(true, src, widthNone, height)
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMeta)
val imageCutout = FaciaImage.getFaciaImage(Some(emptyContent), trailMeta, resolvedMetaData)
val imageCutout = FaciaImage.getFaciaImage(Some(emptyContent), trailMeta, resolvedMetaData, None)
imageCutout should be (None)
}

"should return an Image of type cutout from content tags" in {
val trailMeta = trailMetaDataWithImageCutout(true, None, None, None)
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMeta)
val imageCutout = FaciaImage.getFaciaImage(Some(contentWithContributor), trailMeta, resolvedMetaData)
val imageCutout = FaciaImage.getFaciaImage(Some(contentWithContributor), trailMeta, resolvedMetaData, None)
imageCutout should be (Some(Cutout(bylineImageUrl, None, None)))
}

"should not return an Image of type cutout from content tags if imageCutoutReplace is false" in {
val trailMeta = trailMetaDataWithImageCutout(false, None, None, None)
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMeta)
val imageCutout = FaciaImage.getFaciaImage(Some(contentWithContributor), trailMeta, resolvedMetaData)
val imageCutout = FaciaImage.getFaciaImage(Some(contentWithContributor), trailMeta, resolvedMetaData, None)
imageCutout should be (None)
}

Expand All @@ -90,7 +90,7 @@ class FaciaImageCutoutTest extends AnyFreeSpec with Matchers with TestContent {

val trailMeta = trailMetaDataWithImageCutout(true, src, width, height)
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMeta)
val imageCutout = FaciaImage.getFaciaImage(None, trailMeta, resolvedMetaData)
val imageCutout = FaciaImage.getFaciaImage(None, trailMeta, resolvedMetaData, None)
imageCutout should be (Some(Cutout("src", width, height)))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ class FaciaImageReplaceTest extends AnyFlatSpec with Matchers {

"Image" should "give an Image of type default when it is not set" in {
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMetaDataWithoutImageReplace)
FaciaImage.getFaciaImage(None, trailMetaDataWithoutImageReplace, resolvedMetaData) should be (None)
FaciaImage.getFaciaImage(None, trailMetaDataWithoutImageReplace, resolvedMetaData, None) should be (None)
}

it should "give back an Image when true" in {
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMetaDataWithImageReplace)
FaciaImage.getFaciaImage(None, trailMetaDataWithImageReplace, resolvedMetaData) should be (Some(Replace("theImageSrc", "theImageSrcWidth", "theImageSrcHeight", None)))
FaciaImage.getFaciaImage(None, trailMetaDataWithImageReplace, resolvedMetaData, None) should be (Some(Replace("theImageSrc", "theImageSrcWidth", "theImageSrcHeight", None)))
}

it should "give back an ImageSource when imageSource present in metadata" in {
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMetaDataWithImageSource)
FaciaImage.getFaciaImage(None, trailMetaDataWithImageSource, resolvedMetaData) should be (Some(Replace("theImageSrcAsset", "500", "300", None)))
FaciaImage.getFaciaImage(None, trailMetaDataWithImageSource, resolvedMetaData, None) should be (Some(Replace("theImageSrcAsset", "500", "300", None)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ class FaciaImageSlideshowTest extends AnyFlatSpec with Matchers {

"Image" should "give a None if when imageSlideshowReplace not set" in {
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMetaDataWithoutImageSlideshowReplace)
FaciaImage.getFaciaImage(None, trailMetaDataWithoutImageSlideshowReplace, resolvedMetaData) should be (None)
FaciaImage.getFaciaImage(None, trailMetaDataWithoutImageSlideshowReplace, resolvedMetaData, None) should be (None)
}

it should "give back an ImageGallery when true" in {
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMetaDataWithImageSlideshowReplace)
FaciaImage.getFaciaImage(None, trailMetaDataWithImageSlideshowReplace, resolvedMetaData) should be (Some(ImageSlideshow(List(Replace("theImageSrcOne", "theImageSrcWidthOne", "theImageSrcHeightOne", None), Replace("theImageSrcTwo", "theImageSrcWidthTwo", "theImageSrcHeightTwo", None), Replace("theImageSrcThree", "theImageSrcWidthThree", "theImageSrcHeightThree", None)))))
FaciaImage.getFaciaImage(None, trailMetaDataWithImageSlideshowReplace, resolvedMetaData, None) should be (Some(ImageSlideshow(List(Replace("theImageSrcOne", "theImageSrcWidthOne", "theImageSrcHeightOne", None), Replace("theImageSrcTwo", "theImageSrcWidthTwo", "theImageSrcHeightTwo", None), Replace("theImageSrcThree", "theImageSrcWidthThree", "theImageSrcHeightThree", None)))))
}

it should "give back an ImageGallery when true, with caption set on one image" in {
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMetaDataWithImageSlideshowReplaceAndCaptionSetOnOneImage)
FaciaImage.getFaciaImage(None, trailMetaDataWithImageSlideshowReplaceAndCaptionSetOnOneImage, resolvedMetaData) should be (Some(ImageSlideshow(List(Replace("theImageSrcOne", "theImageSrcWidthOne", "theImageSrcHeightOne", None), Replace("theImageSrcTwo", "theImageSrcWidthTwo", "theImageSrcHeightTwo", None), Replace("theImageSrcThree", "theImageSrcWidthThree", "theImageSrcHeightThree", None), Replace("theImageSrcFour", "theImageSrcWidthFour", "theImageSrcHeightFour", Some("exampleCaption"))))))
FaciaImage.getFaciaImage(None, trailMetaDataWithImageSlideshowReplaceAndCaptionSetOnOneImage, resolvedMetaData, None) should be (Some(ImageSlideshow(List(Replace("theImageSrcOne", "theImageSrcWidthOne", "theImageSrcHeightOne", None), Replace("theImageSrcTwo", "theImageSrcWidthTwo", "theImageSrcHeightTwo", None), Replace("theImageSrcThree", "theImageSrcWidthThree", "theImageSrcHeightThree", None), Replace("theImageSrcFour", "theImageSrcWidthFour", "theImageSrcHeightFour", Some("exampleCaption"))))))
}

it should "give back a None when imageSlideshowReplace true with no assets" in {
val resolvedMetaData = ResolvedMetaData.fromTrailMetaData(trailMetaDataWithImageSlideshowReplaceAndNoAssets)
FaciaImage.getFaciaImage(None, trailMetaDataWithImageSlideshowReplaceAndNoAssets, resolvedMetaData) should be (None)
FaciaImage.getFaciaImage(None, trailMetaDataWithImageSlideshowReplaceAndNoAssets, resolvedMetaData, None) should be (None)
}
}

0 comments on commit 8f6753e

Please sign in to comment.