Skip to content

Commit

Permalink
Merge pull request #196 from klaviyo/ab/CHNL-6170/renamed-enum-cases
Browse files Browse the repository at this point in the history
[CHNL-6170] renamed enum cases
  • Loading branch information
ab1470 authored Sep 5, 2024
2 parents 6aa3946 + 53721f4 commit 8216e96
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
22 changes: 11 additions & 11 deletions Sources/KlaviyoSwift/Models/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import KlaviyoCore

public struct Event: Equatable {
public enum EventName: Equatable {
case OpenedAppMetric
case ViewedProductMetric
case AddedToCartMetric
case StartedCheckoutMetric
case CustomEvent(String)
case openedAppMetric
case viewedProductMetric
case addedToCartMetric
case startedCheckoutMetric
case customEvent(String)

internal static var _openedPush: EventName {
EventName.CustomEvent("_openedPush")
EventName.customEvent("_openedPush")
}
}

Expand Down Expand Up @@ -91,11 +91,11 @@ extension Event.EventName {
public var value: String {
switch self {
case ._openedPush: return "$opened_push"
case .OpenedAppMetric: return "Opened App"
case .ViewedProductMetric: return "Viewed Product"
case .AddedToCartMetric: return "Added to Cart"
case .StartedCheckoutMetric: return "Started Checkout"
case let .CustomEvent(value): return "\(value)"
case .openedAppMetric: return "Opened App"
case .viewedProductMetric: return "Viewed Product"
case .addedToCartMetric: return "Added to Cart"
case .startedCheckoutMetric: return "Started Checkout"
case let .customEvent(value): return "\(value)"
}
}
}
2 changes: 1 addition & 1 deletion Tests/KlaviyoSwiftTests/EventTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ import XCTest
class KlaviyoEventTests: XCTestCase {
func testOpenedPushEvent() {
let openedPushEvent = Event.EventName._openedPush
XCTAssertEqual(openedPushEvent, .CustomEvent("_openedPush"))
XCTAssertEqual(openedPushEvent, .customEvent("_openedPush"))
}
}
4 changes: 2 additions & 2 deletions Tests/KlaviyoSwiftTests/KlaviyoSDKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class KlaviyoSDKTests: XCTestCase {
// MARK: test create event

func testCreateEvent() throws {
let event = Event(name: .OpenedAppMetric)
let event = Event(name: .openedAppMetric)
let expectation = setupActionAssertion(expectedAction: .enqueueEvent(event))

klaviyo.create(event: event)
Expand All @@ -91,7 +91,7 @@ class KlaviyoSDKTests: XCTestCase {
}

func testCreateEventFromDocumentation() throws {
let event = Event(name: .AddedToCartMetric, properties: [
let event = Event(name: .addedToCartMetric, properties: [
"Total Price": 10.99,
"Items Purchased": ["Hot Dog", "Fries", "Shake"]
], value: 10.99)
Expand Down
2 changes: 1 addition & 1 deletion Tests/KlaviyoSwiftTests/StateManagementEdgeCaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,6 @@ class StateManagementEdgeCaseTests: XCTestCase {

extension Event.EventName: CaseIterable {
public static var allCases: [KlaviyoSwift.Event.EventName] {
[._openedPush, .OpenedAppMetric, .ViewedProductMetric, .AddedToCartMetric, .StartedCheckoutMetric, .CustomEvent("someEvent")]
[._openedPush, .openedAppMetric, .viewedProductMetric, .addedToCartMetric, .startedCheckoutMetric, .customEvent("someEvent")]
}
}
4 changes: 2 additions & 2 deletions Tests/KlaviyoSwiftTests/StateManagementTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ class StateManagementTests: XCTestCase {
let initialState = INITILIZING_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())

let event = Event(name: .OpenedAppMetric)
let event = Event(name: .openedAppMetric)
await store.send(.enqueueEvent(event)) {
$0.pendingRequests = [KlaviyoState.PendingRequest.event(event)]
}
Expand All @@ -603,7 +603,7 @@ class StateManagementTests: XCTestCase {
apiKey: XCTUnwrap($0.apiKey),
endpoint: .createEvent(CreateEventPayload(
data: CreateEventPayload.Event(
name: Event.EventName.OpenedAppMetric.value,
name: Event.EventName.openedAppMetric.value,
properties: event.properties,
phoneNumber: $0.phoneNumber,
anonymousId: initialState.anonymousId!,
Expand Down
4 changes: 2 additions & 2 deletions Tests/KlaviyoSwiftTests/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ extension Event {
"Device Manufacturer": "Orange",
"Device Model": "jPhone 1,1"
] as [String: Any]
static let test = Self(name: .CustomEvent("blob"), properties: nil, time: KlaviyoEnvironment.test().date())
static let test = Self(name: .customEvent("blob"), properties: nil, time: KlaviyoEnvironment.test().date())
}

extension Event.Metric {
static let test = Self(name: .CustomEvent("blob"))
static let test = Self(name: .customEvent("blob"))
}

extension KlaviyoState {
Expand Down

0 comments on commit 8216e96

Please sign in to comment.