Skip to content

Commit

Permalink
Merge pull request #273 from JPToroDev/011724c
Browse files Browse the repository at this point in the history
Update test names to follow best practices outlined in Apple's Swift Testing documentation.
  • Loading branch information
twostraws authored Jan 22, 2025
2 parents df99c56 + bd9e4ea commit 2d32a2d
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 41 deletions.
6 changes: 3 additions & 3 deletions Tests/IgniteTesting/Elements/Abbreviation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct AbbreviationTests {
let publishingContext = ElementTest.publishingContext

@Test("Basic Abbreviation Test", arguments: ["abbr"], ["abbreviation"])
func test_basic(abbreviation: String, description: String) async throws {
func basic(abbreviation: String, description: String) async throws {
let element = Abbreviation(abbreviation, description: description)
let output = element.render(context: publishingContext)

Expand All @@ -27,7 +27,7 @@ struct AbbreviationTests {
@Test(
"Single Element Abbreviation Test", arguments: ["abbreviation"],
["abbr"])
func test_singleElement(description: String, abbreviation: String)
func singleElement(description: String, abbreviation: String)
async throws {
let element = Abbreviation(description) { Strong(abbreviation) }
let output = element.render(context: publishingContext)
Expand All @@ -38,7 +38,7 @@ struct AbbreviationTests {
)
}
@Test("Builder Abbreviation Test", arguments: ["abbreviation"], ["abbr"])
func test_builder(description: String, abbreviation: String) async throws {
func builder(description: String, abbreviation: String) async throws {
let element = Abbreviation(description) {
Strong {
abbreviation
Expand Down
14 changes: 7 additions & 7 deletions Tests/IgniteTesting/Elements/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct AttributesTest {
private nonisolated static let tags: [String] = ["body", "btn", "img", "div", "nav", "section"]

@Test("Checks that meta highlighting tags are sorted in the head element")
func test_highligther_themes_are_sorted() async throws {
func highligtherThemes_areSorted() async throws {
let links = MetaLink.highlighterThemeMetaLinks(for: [.xcodeDark, .githubDark, .twilight])
let output = links.map { $0.render(context: publishingContext )}

Expand All @@ -31,7 +31,7 @@ struct AttributesTest {
}

@Test("Checks that classes are sorted", arguments: tags)
func test_classes_are_sorted(tag: String) async throws {
func classes_areSorted(tag: String) async throws {
let element = Tag(tag) {}.class("foo", "bar", "baz", "qux")
let output = element.render(context: publishingContext)
let expected = "<\(tag) class=\"bar baz foo qux\"></\(tag)>"
Expand All @@ -42,7 +42,7 @@ struct AttributesTest {
}

@Test("Checks that custom attributes are sorted", arguments: Self.tags)
func test_custom_attributes_are_sorted(tag: String) async throws {
func customAttributes_areSorted(tag: String) async throws {
let element = Tag(tag) {}
.customAttribute(name: "qux", value: "qux")
.customAttribute(name: "baz", value: "baz")
Expand All @@ -56,7 +56,7 @@ struct AttributesTest {
}

@Test("Checks that events are sorted", arguments: Self.tags)
func test_events_are_sorted(tag: String) async throws {
func events_areSorted(tag: String) async throws {
let element = Tag(tag) {}
.addEvent(name: "bar", actions: [ShowAlert(message: "bar")])
.addEvent(name: "baz", actions: [ShowAlert(message: "baz")])
Expand All @@ -72,7 +72,7 @@ struct AttributesTest {
}

@Test("Checks that styles are sorted", arguments: Self.tags)
func test_styles_are_sorted(tag: String) async throws {
func styles_areSorted(tag: String) async throws {
let element = Tag(tag) {}
.style("foo: bar", "bar: baz", "baz: qux", "qux: foo")
let output = element.render(context: publishingContext)
Expand All @@ -83,7 +83,7 @@ struct AttributesTest {
}

@Test("Checks that aria attributes are sorted", arguments: Self.tags)
func test_aria_attributes_are_sorted(tag: String) async throws {
func ariaAttributes_areSorted(tag: String) async throws {
let element = Tag(tag) {}
.aria("foo", "bar")
.aria("baz", "qux")
Expand All @@ -97,7 +97,7 @@ struct AttributesTest {
}

@Test("Checks that data attributes are sorted", arguments: Self.tags)
func test_data_attributes_are_sorted(tag: String) async throws {
func dataAttributes_areSorted(tag: String) async throws {
let element = Tag(tag) {}
.data("foo", "bar")
.data("baz", "qux")
Expand Down
4 changes: 2 additions & 2 deletions Tests/IgniteTesting/Elements/Audio.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Lone File Audio", arguments: ["/audio/example.mp3"])
func test_loneFileAudio(audioFile: String) async throws {
func loneFileAudio(audioFile: String) async throws {
let element = Audio(audioFile)
let output = element.render(context: publishingContext)

Expand All @@ -30,7 +30,7 @@ import Testing
@Test(
"Multiple File Audio", arguments: ["/audio/example1.mp3"],
["/audio/example1.wav"])
func test_multiFileAudio(audioFile1: String, audioFile2: String)
func multiFileAudio(audioFile1: String, audioFile2: String)
async throws {
let element = Audio(audioFile1, audioFile2)
let output = element.render(context: publishingContext)
Expand Down
4 changes: 2 additions & 2 deletions Tests/IgniteTesting/Elements/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Image Test", arguments: ["/images/example.jpg"], ["Example image"])
func test_named(image: String, description: String) async throws {
func named(image: String, description: String) async throws {
let element = Image(image, description: description)
let output = element.render(context: publishingContext)
let normalizedOutput = ElementTest.normalizeHTML(output)
Expand All @@ -26,7 +26,7 @@ import Testing
== "<img alt=\"Example image\" src=\"/images/example.jpg\"/>")
}
@Test("Icon Image Test", arguments: ["browser-safari"], ["Safari logo"])
func test_icon(systemName: String, description: String) async throws {
func icon(systemName: String, description: String) async throws {
let element = Image(
systemName: systemName, description: description)
let output = element.render(context: publishingContext)
Expand Down
4 changes: 2 additions & 2 deletions Tests/IgniteTesting/Elements/NavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Default Column Width Test")
func test_defaultColumnWidth() async throws {
func defaultColumnWidth() async throws {
let element = NavigationBar().width(.viewport)
let output = element.render(context: publishingContext)

#expect(output.contains("col container-fluid"))
}

@Test("Column With Value Test", arguments: [3, 6, 12])
func test_columnWidthValueSet(count: Int) async throws {
func columnWidthValueSet(count: Int) async throws {
let element = NavigationBar().width(.count(count))
let output = element.render(context: publishingContext)

Expand Down
6 changes: 3 additions & 3 deletions Tests/IgniteTesting/Elements/Script.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Code Test")
func test_code() async throws {
func code() async throws {
let element = Script(code: "javascript code")
let output = element.render(context: publishingContext)

#expect(output == "<script>javascript code</script>")
}
@Test("File Test", arguments: ["/code.js"])
func test_file(scriptFile: String) async throws {
func file(scriptFile: String) async throws {
let element = Script(file: scriptFile)
let output = element.render(context: publishingContext)

#expect(output == "<script src=\"\(scriptFile)\"></script>")
}
@Test("Attributes Test", arguments: ["/code.js"])
func test_attributes(scriptFile: String) async throws {
func attributes(scriptFile: String) async throws {
let element = Script(file: scriptFile)
.data("key", "value")
.customAttribute(name: "custom", value: "part")
Expand Down
4 changes: 2 additions & 2 deletions Tests/IgniteTesting/Elements/Span.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Single Element Test", arguments: ["This is a test", "Another test"])
func test_singleElement(spanText: String) async throws {
func singleElement(spanText: String) async throws {
let element = Span(spanText)
let output = element.render(context: publishingContext)

#expect(output == "<span>\(spanText)</span>")
}
@Test("Builder Test", arguments: ["This is a test", "Another test"])
func test_builder(spanText: String) async throws {
func builder(spanText: String) async throws {
let element = Span { spanText }
let output = element.render(context: publishingContext)

Expand Down
2 changes: 1 addition & 1 deletion Tests/IgniteTesting/Elements/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Single Element", arguments: ["This is a test", ""])
func test_singleElement(element: String) async throws {
func singleElement(element: String) async throws {
let element = element
let output = element.render(context: publishingContext)

Expand Down
4 changes: 2 additions & 2 deletions Tests/IgniteTesting/Elements/Strong.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Single Element Test", arguments: ["This is a test", "Another test", ""])
func test_singleElement(strongText: String) async throws {
func singleElement(strongText: String) async throws {
let element = Strong(strongText)
let output = element.render(context: publishingContext)

#expect(output == "<strong>\(strongText)</strong>")
}

@Test("Builder Test", arguments: ["This is a test", "Another test", ""])
func test_builder(strongText: String) async throws {
func builder(strongText: String) async throws {
let element = Strong { strongText }
let output = element.render(context: publishingContext)

Expand Down
8 changes: 4 additions & 4 deletions Tests/IgniteTesting/Elements/Text.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Simple String Test")
func test_simpleString() async throws {
func simpleString() async throws {
let element = Text("Hello")
let output = element.render(context: publishingContext)

Expand All @@ -32,7 +32,7 @@ import Testing
#expect(output == "<p>Hello</p>")
}
@Test("Builder with Complex String Test")
func test_complexBuilderString() {
func complexBuilderString() {
let element = Text {
"Hello, "
Emphasis("world")
Expand All @@ -59,7 +59,7 @@ import Testing
@Test(
"Custom Font Test",
arguments: Font.Style.allCases)
func test_customFont(font: Font.Style) async throws {
func customFont(font: Font.Style) async throws {
let element = Text("Hello").font(font)
let output = element.render(context: publishingContext)

Expand All @@ -77,7 +77,7 @@ import Testing
}
}
@Test("Markdown Test")
func test_markdown() async throws {
func markdown() async throws {
let element = Text(
markdown:
"Text in *italics*, text in **bold**, and text in ***bold italics***."
Expand Down
4 changes: 2 additions & 2 deletions Tests/IgniteTesting/Elements/Time.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import Testing

@Test(
"Without DateTime Test", arguments: ["This is a test", "Another test"])
func test_without_datetime(timeText: String) async throws {
func withoutDatetime(timeText: String) async throws {
let element = Time(timeText)
let output = element.render(context: publishingContext)

#expect(output == "<time>\(timeText)</time>")
}
@Test("Builder Test", arguments: ["This is a test", "Another test"])
func test_builder(timeText: String) async throws {
func builder(timeText: String) async throws {
guard
let customTimeInterval = DateComponents(
calendar: .current,
Expand Down
4 changes: 2 additions & 2 deletions Tests/IgniteTesting/Elements/Title.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Empty Title Test", arguments: [""])
func test_empty(emptyTitleText: String) async throws {
func empty(emptyTitleText: String) async throws {
let element = Title(emptyTitleText)
let output = element.render(context: publishingContext)

#expect(output == "<title>\(emptyTitleText) - My Test Site</title>")
}
@Test("Builder Test", arguments: ["Example Page", "Another Example Page"])
func test_builder(titleText: String) async throws {
func builder(titleText: String) async throws {
let element = Title(titleText)
let output = element.render(context: publishingContext)

Expand Down
4 changes: 2 additions & 2 deletions Tests/IgniteTesting/Elements/Video.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Testing
let publishingContext = ElementTest.publishingContext

@Test("Lone File Video Test", arguments: ["/videos/example.mp4"])
func test_loneFileVideo(videoFile: String) async throws {
func loneFileVideo(videoFile: String) async throws {
let element = Video(videoFile)
let output = element.render(context: publishingContext)
let normalizedOutput = ElementTest.normalizeHTML(output)
Expand All @@ -30,7 +30,7 @@ import Testing
@Test(
"Multi-file Video Test", arguments: ["/videos/example1.mp4"],
["/videos/example1.mov"])
func test_multiFileVideo(videoFile1: String, videoFile2: String)
func multiFileVideo(videoFile1: String, videoFile2: String)
async throws {
let element = Video(videoFile1, videoFile2)
let output = element.render(context: publishingContext)
Expand Down
2 changes: 1 addition & 1 deletion Tests/IgniteTesting/NonRoot Elements/SubsiteBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Testing
let publishingContext = ElementTest.publishingSubsiteContext

@Test("Simple Body Test")
func test_body_simple() async throws {
func simpleBody() async throws {
let element = HTMLBody(
for: Page(
title: "TITLE", description: "DESCRIPTION",
Expand Down
4 changes: 2 additions & 2 deletions Tests/IgniteTesting/NonRoot Elements/SubsiteImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Testing
let publishingContext = ElementTest.publishingSubsiteContext

@Test("Image Test", arguments: ["/images/example.jpg"], ["Example image"])
func test_image_named(imageFile: String, description: String) async throws {
func fileImage(imageFile: String, description: String) async throws {
let element = Image(imageFile, description: description)
let output = element.render(context: publishingContext)
let normalizedOutput = ElementTest.normalizeHTML(output)
Expand All @@ -25,7 +25,7 @@ import Testing
== "<img alt=\"\(description)\" src=\"/subsite\(imageFile)\"/>")
}
@Test("Icon Test", arguments: ["browser-safari"], ["Safari logo"])
func test_image_icon(systemName: String, description: String) async throws {
func iconImage(systemName: String, description: String) async throws {
let element = Image(
systemName: systemName, description: description)
let output = element.render(context: publishingContext)
Expand Down
6 changes: 3 additions & 3 deletions Tests/IgniteTesting/NonRoot Elements/SubsiteLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Testing
let publishingContext = ElementTest.publishingSubsiteContext

@Test("String Target Test", arguments: ["/"])
func test_string_target(linkTarget: String) async throws {
func stringTarget(linkTarget: String) async throws {
let element = Link("Go Home", target: linkTarget)
let output = element.render(context: publishingContext)

Expand All @@ -32,7 +32,7 @@ import Testing
}

@Test("Page Target Test")
func test_page_target() async throws {
func pageTarget() async throws {
let element = Link("This is a test", target: TestPage()).linkStyle(
.button)
let output = element.render(context: publishingContext)
Expand All @@ -44,7 +44,7 @@ import Testing
}

@Test("Page Content Test")
func test_page_content() async throws {
func pageContent() async throws {
let element = Link(
target: TestPage(),
content: {
Expand Down
2 changes: 1 addition & 1 deletion Tests/IgniteTesting/NonRoot Elements/SubsiteScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Testing
let publishingContext = ElementTest.publishingSubsiteContext

@Test("Empty Element", arguments: ["/js/bootstrap.bundle.min.js"])
func test_empty(script: String) async throws {
func empty(script: String) async throws {
let element = Script(file: script).render(
context: publishingContext)
let output = element.render(context: publishingContext)
Expand Down

0 comments on commit 2d32a2d

Please sign in to comment.