From aff5421d2cf9a60b0209530b1250d2258cf19aec Mon Sep 17 00:00:00 2001 From: JPToroDev Date: Fri, 17 Jan 2025 14:58:06 -0500 Subject: [PATCH 1/2] Update test names to follow best practices outlined in Apple's Swift Testing documentation. --- Tests/IgniteTesting/Elements/Abbreviation.swift | 6 +++--- Tests/IgniteTesting/Elements/Attributes.swift | 14 +++++++------- Tests/IgniteTesting/Elements/Audio.swift | 4 ++-- Tests/IgniteTesting/Elements/Image.swift | 4 ++-- Tests/IgniteTesting/Elements/NavigationBar.swift | 4 ++-- Tests/IgniteTesting/Elements/Script.swift | 6 +++--- Tests/IgniteTesting/Elements/Span.swift | 4 ++-- Tests/IgniteTesting/Elements/String.swift | 14 +++++++------- Tests/IgniteTesting/Elements/Strong.swift | 4 ++-- Tests/IgniteTesting/Elements/Text.swift | 8 ++++---- Tests/IgniteTesting/Elements/Time.swift | 4 ++-- Tests/IgniteTesting/Elements/Title.swift | 4 ++-- Tests/IgniteTesting/Elements/Video.swift | 4 ++-- .../NonRoot Elements/SubsiteBody.swift | 2 +- .../NonRoot Elements/SubsiteImage.swift | 4 ++-- .../NonRoot Elements/SubsiteLink.swift | 6 +++--- .../NonRoot Elements/SubsiteScript.swift | 2 +- 17 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Tests/IgniteTesting/Elements/Abbreviation.swift b/Tests/IgniteTesting/Elements/Abbreviation.swift index 9a7cb295..0e323742 100644 --- a/Tests/IgniteTesting/Elements/Abbreviation.swift +++ b/Tests/IgniteTesting/Elements/Abbreviation.swift @@ -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) @@ -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) @@ -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 diff --git a/Tests/IgniteTesting/Elements/Attributes.swift b/Tests/IgniteTesting/Elements/Attributes.swift index e50fcd72..6ee959e9 100644 --- a/Tests/IgniteTesting/Elements/Attributes.swift +++ b/Tests/IgniteTesting/Elements/Attributes.swift @@ -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 )} @@ -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\">" @@ -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") @@ -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")]) @@ -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) @@ -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") @@ -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") diff --git a/Tests/IgniteTesting/Elements/Audio.swift b/Tests/IgniteTesting/Elements/Audio.swift index f2c53466..3ac24356 100644 --- a/Tests/IgniteTesting/Elements/Audio.swift +++ b/Tests/IgniteTesting/Elements/Audio.swift @@ -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) @@ -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) diff --git a/Tests/IgniteTesting/Elements/Image.swift b/Tests/IgniteTesting/Elements/Image.swift index 588d0a80..3f40324e 100644 --- a/Tests/IgniteTesting/Elements/Image.swift +++ b/Tests/IgniteTesting/Elements/Image.swift @@ -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) @@ -26,7 +26,7 @@ import Testing == "\"Example") } @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) diff --git a/Tests/IgniteTesting/Elements/NavigationBar.swift b/Tests/IgniteTesting/Elements/NavigationBar.swift index fd8f18b8..90b4d9ec 100644 --- a/Tests/IgniteTesting/Elements/NavigationBar.swift +++ b/Tests/IgniteTesting/Elements/NavigationBar.swift @@ -15,7 +15,7 @@ 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) @@ -23,7 +23,7 @@ import Testing } @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) diff --git a/Tests/IgniteTesting/Elements/Script.swift b/Tests/IgniteTesting/Elements/Script.swift index 3545dac3..a2a7fe1b 100644 --- a/Tests/IgniteTesting/Elements/Script.swift +++ b/Tests/IgniteTesting/Elements/Script.swift @@ -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 == "") } @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 == "") } @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") diff --git a/Tests/IgniteTesting/Elements/Span.swift b/Tests/IgniteTesting/Elements/Span.swift index e55193b8..2aeccc42 100644 --- a/Tests/IgniteTesting/Elements/Span.swift +++ b/Tests/IgniteTesting/Elements/Span.swift @@ -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 == "\(spanText)") } @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) diff --git a/Tests/IgniteTesting/Elements/String.swift b/Tests/IgniteTesting/Elements/String.swift index 88dfd33f..3a9400b5 100644 --- a/Tests/IgniteTesting/Elements/String.swift +++ b/Tests/IgniteTesting/Elements/String.swift @@ -1,5 +1,5 @@ // -// String.swift +// PlainText.swift // Ignite // https://www.github.com/twostraws/Ignite // See LICENSE for license information. @@ -10,16 +10,16 @@ import Testing @testable import Ignite -/// Tests for Strings (aka Plain Text) -@Suite("String Tests") -@MainActor struct StringTests { +/// Tests for plain text. +@Suite("Plain Text Tests") +@MainActor struct PlainTextTests { let publishingContext = ElementTest.publishingContext - @Test("Single Element", arguments: ["This is a test", ""]) - func test_singleElement(element: String) async throws { + @Test("Single Element", arguments: ["This is a test"]) + func singleElement(element: String) async throws { let element = element let output = element.render(context: publishingContext) - #expect(output == element) + #expect(output == "This is a test") } } diff --git a/Tests/IgniteTesting/Elements/Strong.swift b/Tests/IgniteTesting/Elements/Strong.swift index d8fba1d2..0cfdab45 100644 --- a/Tests/IgniteTesting/Elements/Strong.swift +++ b/Tests/IgniteTesting/Elements/Strong.swift @@ -16,7 +16,7 @@ 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) @@ -24,7 +24,7 @@ import Testing } @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) diff --git a/Tests/IgniteTesting/Elements/Text.swift b/Tests/IgniteTesting/Elements/Text.swift index ae96ba42..8b48c6dd 100644 --- a/Tests/IgniteTesting/Elements/Text.swift +++ b/Tests/IgniteTesting/Elements/Text.swift @@ -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) @@ -32,7 +32,7 @@ import Testing #expect(output == "

Hello

") } @Test("Builder with Complex String Test") - func test_complexBuilderString() { + func complexBuilderString() { let element = Text { "Hello, " Emphasis("world") @@ -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) @@ -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***." diff --git a/Tests/IgniteTesting/Elements/Time.swift b/Tests/IgniteTesting/Elements/Time.swift index f7707901..40af5aa9 100644 --- a/Tests/IgniteTesting/Elements/Time.swift +++ b/Tests/IgniteTesting/Elements/Time.swift @@ -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 == "") } @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, diff --git a/Tests/IgniteTesting/Elements/Title.swift b/Tests/IgniteTesting/Elements/Title.swift index b9a84303..cf81705b 100644 --- a/Tests/IgniteTesting/Elements/Title.swift +++ b/Tests/IgniteTesting/Elements/Title.swift @@ -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 == "\(emptyTitleText) - My Test Site") } @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) diff --git a/Tests/IgniteTesting/Elements/Video.swift b/Tests/IgniteTesting/Elements/Video.swift index c1d40568..3569fb74 100644 --- a/Tests/IgniteTesting/Elements/Video.swift +++ b/Tests/IgniteTesting/Elements/Video.swift @@ -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) @@ -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) diff --git a/Tests/IgniteTesting/NonRoot Elements/SubsiteBody.swift b/Tests/IgniteTesting/NonRoot Elements/SubsiteBody.swift index 258ddc17..ffdcd1dc 100644 --- a/Tests/IgniteTesting/NonRoot Elements/SubsiteBody.swift +++ b/Tests/IgniteTesting/NonRoot Elements/SubsiteBody.swift @@ -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", diff --git a/Tests/IgniteTesting/NonRoot Elements/SubsiteImage.swift b/Tests/IgniteTesting/NonRoot Elements/SubsiteImage.swift index 63cfa88a..f72d0097 100644 --- a/Tests/IgniteTesting/NonRoot Elements/SubsiteImage.swift +++ b/Tests/IgniteTesting/NonRoot Elements/SubsiteImage.swift @@ -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) @@ -25,7 +25,7 @@ import Testing == "\"\(description)\"") } @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) diff --git a/Tests/IgniteTesting/NonRoot Elements/SubsiteLink.swift b/Tests/IgniteTesting/NonRoot Elements/SubsiteLink.swift index b360e18a..7db96ab6 100644 --- a/Tests/IgniteTesting/NonRoot Elements/SubsiteLink.swift +++ b/Tests/IgniteTesting/NonRoot Elements/SubsiteLink.swift @@ -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) @@ -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) @@ -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: { diff --git a/Tests/IgniteTesting/NonRoot Elements/SubsiteScript.swift b/Tests/IgniteTesting/NonRoot Elements/SubsiteScript.swift index 7702fde3..56aec187 100644 --- a/Tests/IgniteTesting/NonRoot Elements/SubsiteScript.swift +++ b/Tests/IgniteTesting/NonRoot Elements/SubsiteScript.swift @@ -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) From 9aafe5d5818b9f2d6bccc093d3787a4d4a97a341 Mon Sep 17 00:00:00 2001 From: JPToroDev Date: Fri, 17 Jan 2025 15:00:10 -0500 Subject: [PATCH 2/2] Restore updated string test. --- Tests/IgniteTesting/Elements/String.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/IgniteTesting/Elements/String.swift b/Tests/IgniteTesting/Elements/String.swift index 3a9400b5..f752bf99 100644 --- a/Tests/IgniteTesting/Elements/String.swift +++ b/Tests/IgniteTesting/Elements/String.swift @@ -1,5 +1,5 @@ // -// PlainText.swift +// String.swift // Ignite // https://www.github.com/twostraws/Ignite // See LICENSE for license information. @@ -10,16 +10,16 @@ import Testing @testable import Ignite -/// Tests for plain text. -@Suite("Plain Text Tests") -@MainActor struct PlainTextTests { +/// Tests for Strings (aka Plain Text) +@Suite("String Tests") +@MainActor struct StringTests { let publishingContext = ElementTest.publishingContext - @Test("Single Element", arguments: ["This is a test"]) + @Test("Single Element", arguments: ["This is a test", ""]) func singleElement(element: String) async throws { let element = element let output = element.render(context: publishingContext) - #expect(output == "This is a test") + #expect(output == element) } }