Social Card tweaks in the Infrastructure package. (#30)

This PR contains the work done to address certain tweaks in the newly-introduced _Social Card_ types in the **Infrastructure** package.

Reviewed-on: rock-n-code/loud-amsterdam#30
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
This commit is contained in:
2026-08-01 11:25:36 +00:00
committed by javier
parent 5f4316b85b
commit 5c9fde9d41
5 changed files with 88 additions and 102 deletions
@@ -27,17 +27,17 @@ struct SocialCardTests {
)
#expect(card.tags == [
.init(attribute: .property, content: "website", name: .type),
.init(attribute: .property, content: "A Site", name: .siteName),
.init(attribute: .property, content: "A Title", name: .title),
.init(attribute: .property, content: "A summary.", name: .description),
.init(attribute: .property, content: "https://site.example/", name: .url),
.init(attribute: .property, content: "en", name: .locale),
.init(attribute: .property, content: "https://site.example/img/card.png", name: .image),
.init(attribute: .property, content: "2400", name: .imageWidth),
.init(attribute: .property, content: "1260", name: .imageHeight),
.init(attribute: .property, content: "An image.", name: .imageAlt),
.init(attribute: .name, content: "summary_large_image", name: .twitter),
.init("website", name: .type),
.init("A Site", name: .siteName),
.init("A Title", name: .title),
.init("A summary.", name: .description),
.init("https://site.example/", name: .url),
.init("en", name: .locale),
.init("https://site.example/img/card.png", name: .image),
.init("2400", name: .imageWidth),
.init("1260", name: .imageHeight),
.init("An image.", name: .imageAlt),
.init("summary_large_image", name: .twitter),
])
}
@@ -46,9 +46,9 @@ struct SocialCardTests {
let card = SocialCard(title: "A Title")
#expect(card.tags == [
.init(attribute: .property, content: "website", name: .type),
.init(attribute: .property, content: "A Title", name: .title),
.init(attribute: .name, content: "summary_large_image", name: .twitter),
.init("website", name: .type),
.init("A Title", name: .title),
.init("summary_large_image", name: .twitter),
])
}
@@ -77,8 +77,15 @@ struct SocialCardTests {
style: .summary
)
#expect(card.tags.contains(.init(attribute: .property, content: "article", name: .type)))
#expect(card.tags.contains(.init(attribute: .name, content: "summary", name: .twitter)))
#expect(card.tags.contains(.init("article", name: .type)))
#expect(card.tags.contains(.init("summary", name: .twitter)))
}
@Test
func `keys a tag by the attribute its name dictates`() {
#expect(SocialCard.Tag.Name.twitter.attribute == .name)
#expect(SocialCard.Tag.Name.title.attribute == .property)
#expect(SocialCard.Tag("website", name: .type).attribute == .property)
}
}