Project updates from Template (#1)
This PR contains the latest updates from the generic Website template, which have been added while working on #loud-amsterdam. Reviewed-on: #1 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #1.
This commit is contained in:
+59
@@ -0,0 +1,59 @@
|
||||
import Elementary
|
||||
import Testing
|
||||
|
||||
@testable import Infrastructure
|
||||
|
||||
@Suite(
|
||||
"Analytics.Event+Tagging extension",
|
||||
.tags(.extension)
|
||||
)
|
||||
struct AnalyticsEventTaggingTests {
|
||||
|
||||
// MARK: Methods tests
|
||||
|
||||
@Test
|
||||
func `applies the event name to the tag`() {
|
||||
let markup = a(.href("/")) { "Listen" }
|
||||
.attributes(contentsOf: Analytics.Event(name: "instagram").tagging())
|
||||
|
||||
#expect(markup.render().contains(#"data-umami-event="instagram""#))
|
||||
}
|
||||
|
||||
@Test
|
||||
func `applies every event attribute to the tag`() {
|
||||
let event = Analytics.Event(
|
||||
name: "playlist",
|
||||
properties: ["set": "avc-xi"]
|
||||
)
|
||||
|
||||
let markup = button {}
|
||||
.attributes(contentsOf: event.tagging())
|
||||
let rendered = markup.render()
|
||||
|
||||
#expect(rendered.contains(#"data-umami-event="playlist""#))
|
||||
#expect(rendered.contains(#"data-umami-event-set="avc-xi""#))
|
||||
}
|
||||
|
||||
@Test
|
||||
func `returns one attribute per event attribute`() {
|
||||
let event = Analytics.Event(
|
||||
name: "playlist",
|
||||
properties: ["set": "avc-xi"]
|
||||
)
|
||||
|
||||
let attributes: [HTMLAttribute<HTMLTag.a>] = event.tagging()
|
||||
|
||||
#expect(attributes.count == event.attributes.count)
|
||||
}
|
||||
|
||||
@Test
|
||||
func `applies the event name to an SVG tag`() {
|
||||
// `SVGTag.path` is no `HTMLTrait.Attributes.Global`, so this stops compiling if the method narrows back to HTML tags.
|
||||
let rendered = SVG.path {}
|
||||
.attributes(contentsOf: Analytics.Event(name: "logo").tagging())
|
||||
.render()
|
||||
|
||||
#expect(rendered.contains(#"data-umami-event="logo""#))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user