Added the "analytics.recorder" flag to the Website service.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import Configuration
|
||||
import Infrastructure
|
||||
import Persistence
|
||||
import Testing
|
||||
|
||||
@testable import Website
|
||||
@testable import WebsiteLibrary
|
||||
|
||||
@Suite("ConfigReader properties")
|
||||
struct ConfigReaderPropertiesTests {
|
||||
|
||||
// MARK: Functional tests
|
||||
|
||||
@Test
|
||||
func `analytics to default to the production tracker`() throws {
|
||||
let analytics = try #require(reader().analytics)
|
||||
|
||||
#expect(analytics.scriptURL == .Analytics.scriptURL)
|
||||
#expect(analytics.websiteID == .Analytics.websiteID)
|
||||
#expect(analytics.domains == .Analytics.domains)
|
||||
#expect(analytics.excludeHash)
|
||||
#expect(analytics.doNotTrack)
|
||||
#expect(analytics.performance)
|
||||
#expect(analytics.recorder)
|
||||
}
|
||||
|
||||
@Test
|
||||
func `analytics to switch recorder mode off when configured`() throws {
|
||||
let analytics = try #require(reader(values: [
|
||||
.Analytics.recorder: false
|
||||
]).analytics)
|
||||
|
||||
#expect(!analytics.recorder)
|
||||
}
|
||||
|
||||
@Test
|
||||
func `analytics to override the website id and domains when configured`() throws {
|
||||
let analytics = try #require(reader(values: [
|
||||
.Analytics.websiteID: "custom-website-id",
|
||||
.Analytics.domains: "staging.loud.amsterdam"
|
||||
]).analytics)
|
||||
|
||||
#expect(analytics.websiteID == "custom-website-id")
|
||||
#expect(analytics.domains == "staging.loud.amsterdam")
|
||||
#expect(analytics.scriptURL == .Analytics.scriptURL)
|
||||
}
|
||||
|
||||
@Test
|
||||
func `analytics to be omitted when the website id is cleared`() {
|
||||
#expect(reader(values: [.Analytics.websiteID: ""]).analytics == nil)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private extension ConfigReaderPropertiesTests {
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
/// Builds a configuration reader over the given in-memory values alone.
|
||||
func reader(
|
||||
values: [AbsoluteConfigKey: ConfigValue] = [:]
|
||||
) -> ConfigReader {
|
||||
ConfigReader(providers: [
|
||||
InMemoryProvider(values: values)
|
||||
])
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user