Files
resgen.swift/Tests/ResgenSwiftTests/Analytics/AnalyticsSectionTests.swift
T
t.schmitt ac5d9cef58
openium/resgen.swift/pipeline/head There was a failure building this commit
openium/resgen.swift/pipeline/pr-master There was a failure building this commit
Migrate tests from XCTest to Swift Testing
- Convert XCTestCase classes to structs with @Test functions
- Replace XCTAssert* with #expect, and force unwraps/XCTFail with #require
- Resolve test bundle via a class token in the CLI smoke test (Swift Testing
  does not register the .xctest bundle in Bundle.allBundles)
- Rename adaptForXCTest() to adaptForTest()
2026-11-23 15:53:21 +01:00

75 lines
2.1 KiB
Swift

//
// AnalyticsSectionTests.swift
//
//
// Created by Loris Perret on 06/12/2023.
//
import Foundation
import Testing
@testable import ResgenSwift
struct AnalyticsSectionTests {
// MARK: - Matching tags
@Test
func matchingAnalytics() {
// Given
let section = AnalyticsCategory(id: "section_name")
section.definitions = [
{
let def = AnalyticsDefinition(id: "definition_name", name: "", type: .screen)
def.tags = ["ios","iosonly"]
return def
}(),
{
let def = AnalyticsDefinition(id: "definition_name_two", name: "", type: .screen)
def.tags = ["droid","droidonly"]
return def
}()
]
// When
let match1 = section.hasOneOrMoreMatchingTags(tags: ["ios"])
let match2 = section.hasOneOrMoreMatchingTags(tags: ["iosonly"])
let match3 = section.hasOneOrMoreMatchingTags(tags: ["droid"])
let match4 = section.hasOneOrMoreMatchingTags(tags: ["droidonly"])
// Expect
#expect(match1)
#expect(match2)
#expect(match3)
#expect(match4)
}
@Test
func notMatchingAnalytics() {
// Given
let section = AnalyticsCategory(id: "section_name")
section.definitions = [
{
let def = AnalyticsDefinition(id: "definition_name", name: "", type: .screen)
def.tags = ["ios","iosonly"]
return def
}(),
{
let def = AnalyticsDefinition(id: "definition_name_two", name: "", type: .screen)
def.tags = ["droid","droidonly"]
return def
}()
]
// When
let match1 = section.hasOneOrMoreMatchingTags(tags: ["web"])
let match2 = section.hasOneOrMoreMatchingTags(tags: ["webonly"])
let match3 = section.hasOneOrMoreMatchingTags(tags: ["azerty"])
// Expect
#expect(match1 == false)
#expect(match2 == false)
#expect(match3 == false)
}
}