-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into use-jsvalue-not-string-for-dcar
- Loading branch information
Showing
10 changed files
with
159 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
common/test/model/dotcomrendering/EditionsCrosswordRenderingDataModelTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package model.dotcomrendering | ||
|
||
import com.gu.contentapi.client.model.v1.{CapiDateTime, Crossword, CrosswordType, CrosswordDimensions, CrosswordEntry} | ||
import model.dotcomrendering.pageElements.EditionsCrosswordRenderingDataModel | ||
import org.mockito.Mockito.when | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatestplus.mockito.MockitoSugar | ||
import org.joda.time.DateTime | ||
|
||
class EditionsCrosswordRenderingDataModelTest extends AnyFlatSpec with Matchers with MockitoSugar { | ||
val mockEntry = CrosswordEntry( | ||
id = "mockId", | ||
solution = Some("Mock solution"), | ||
) | ||
|
||
val mockCrossword = Crossword( | ||
name = "Mock name", | ||
`type` = CrosswordType.Quick, | ||
number = 1, | ||
date = CapiDateTime(DateTime.now().getMillis(), "date"), | ||
dimensions = CrosswordDimensions(1, 1), | ||
entries = Seq(mockEntry, mockEntry), | ||
solutionAvailable = true, | ||
hasNumbers = false, | ||
randomCluesOrdering = false, | ||
) | ||
|
||
"apply" should "provide solutions when 'dateSolutionAvailable' is in the past" in { | ||
val crossword = mockCrossword.copy( | ||
solutionAvailable = true, | ||
dateSolutionAvailable = Some(CapiDateTime(DateTime.now().minusDays(1).getMillis(), "date")), | ||
) | ||
|
||
val crosswords = | ||
EditionsCrosswordRenderingDataModel(Seq(crossword, crossword)).crosswords.toSeq | ||
|
||
crosswords(0).entries(0).solution shouldBe Some("Mock solution") | ||
crosswords(0).entries(1).solution shouldBe Some("Mock solution") | ||
crosswords(1).entries(0).solution shouldBe Some("Mock solution") | ||
crosswords(1).entries(1).solution shouldBe Some("Mock solution") | ||
} | ||
|
||
"apply" should "provide solutions when 'dateSolutionAvailable' is 'None' and solutionAvailable is 'true'" in { | ||
val crossword = mockCrossword.copy( | ||
solutionAvailable = true, | ||
dateSolutionAvailable = None, | ||
) | ||
|
||
val crosswords = | ||
EditionsCrosswordRenderingDataModel(Seq(crossword, crossword)).crosswords.toSeq | ||
|
||
crosswords(0).entries(0).solution shouldBe Some("Mock solution") | ||
crosswords(0).entries(1).solution shouldBe Some("Mock solution") | ||
crosswords(1).entries(0).solution shouldBe Some("Mock solution") | ||
crosswords(1).entries(1).solution shouldBe Some("Mock solution") | ||
} | ||
|
||
"apply" should "not provide solutions when 'dateSolutionAvailable' is in the future" in { | ||
val crossword = mockCrossword.copy( | ||
solutionAvailable = true, | ||
dateSolutionAvailable = Some(CapiDateTime(DateTime.now().plusDays(1).getMillis(), "date")), | ||
) | ||
|
||
val crosswords = | ||
EditionsCrosswordRenderingDataModel(Seq(crossword, crossword)).crosswords.toSeq | ||
|
||
crosswords(0).entries(0).solution shouldBe None | ||
crosswords(0).entries(1).solution shouldBe None | ||
crosswords(1).entries(0).solution shouldBe None | ||
crosswords(1).entries(1).solution shouldBe None | ||
} | ||
|
||
"apply" should "not provide solutions when 'dateSolutionAvailable' is 'None' and solutionAvailable is 'false'" in { | ||
val crossword = mockCrossword.copy( | ||
solutionAvailable = false, | ||
dateSolutionAvailable = None, | ||
) | ||
|
||
val crosswords = | ||
EditionsCrosswordRenderingDataModel(Seq(crossword, crossword)).crosswords.toSeq | ||
|
||
crosswords(0).entries(0).solution shouldBe None | ||
crosswords(0).entries(1).solution shouldBe None | ||
crosswords(1).entries(0).solution shouldBe None | ||
crosswords(1).entries(1).solution shouldBe None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=1.10.2 | ||
sbt.version=1.10.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters