Implemented phase 1 for the POC prototype in the Website service.

This commit is contained in:
javier committed 2026-09-21 11:16:52 +02:00
1 parent 6d7ab4bcba
commit ea89ea892a
37 files changed
+4173 -43

No files matched your search

@@ -0,0 +1,82 @@
import Persistence
import Testing
@testable import WebsiteLibrary
@Suite(
"Listing+Display extension",
.tags(.extensionTests)
)
struct ListingDisplayTests {
// MARK: Computed tests
@Test(arguments: zip(
[9.8, 9.0, 8.5, 7.0, 6.5],
[Chip.Tone.good, .good, .neutral, .neutral, .warn]
))
func `tones a slab's chip by its grade`(
grade: Double,
expects tone: Chip.Tone
) {
let chip = Listing.stub(grade: grade).chip
#expect(chip.label == "CGC \(grade)")
#expect(chip.tone == tone)
#expect(chip.isCertified)
}
@Test
func `marks a raw issue's chip as seller-graded`() {
let chip = Listing.stub(grader: nil, grade: 9.4, condition: "NM").chip
#expect(chip.label == "Raw · NM")
#expect(chip.tone == .neutral)
#expect(!chip.isCertified)
}
@Test
func `states a collected edition's condition alone`() {
#expect(Listing.stub(format: "manga", grader: nil, grade: nil, condition: "Like new").chip.label == "Like new")
}
@Test
func `leads a collected edition's summary with its format`() {
#expect(Listing.stub().summary == "Meridian Comics · 2019 · 1st print")
#expect(Listing.stub(format: "hardcovers").summary == "Hardcover · Meridian Comics · 2019 · 1st print")
}
@Test
func `derives the paths from the slugs`() {
#expect(Listing.stub().path == "/listing/nightward-1")
#expect(Shop.stub().path == "/shop/kestrel-row-comics")
}
@Test(arguments: zip(
["Kestrel Row Comics", "Inkwell & Staple", "Silverfish"],
["KR", "IS", "S"]
))
func `monogram`(
of name: String,
expects monogram: String
) {
#expect(Shop.stub(name: name).monogram == monogram)
}
@Test(arguments: zip(
[24_000, 1_250, 5, 0],
["€240", "€12.50", "€0.05", "€0"]
))
func `euros`(
of cents: Int,
expects price: String
) {
#expect(cents.euros == price)
}
@Test
func `returns to the gated action's path after sign-in`() {
#expect(String.Route.signIn(returningTo: "/shop/a?keys=1&page=2") == "/sign-in?return=/shop/a%3Fkeys%3D1%26page%3D2")
}
}