Skip to content

Commit

Permalink
trimming white spaces in identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaysubra committed Apr 10, 2024
1 parent 45ec195 commit adff271
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/KlaviyoSwift/KlaviyoState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ extension Profile {

extension String {
fileprivate func isNotEmptyOrSame(as state: String?, identifier: String) -> Bool {
let incoming = self
let incoming = trimmingCharacters(in: .whitespacesAndNewlines)
if incoming.isEmpty || incoming == state {
logDevWarning(for: identifier)
}
Expand Down
21 changes: 21 additions & 0 deletions Tests/KlaviyoSwiftTests/StateManagementEdgeCaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ class StateManagementEdgeCaseTests: XCTestCase {
_ = await store.send(.setEmail(""))
}

func testSetEmailWithWhiteSpace() async throws {
let initialState = INITIALIZED_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())

_ = await store.send(.setEmail(" "))
}

// MARK: - Set External Id

@MainActor
Expand Down Expand Up @@ -196,6 +203,13 @@ class StateManagementEdgeCaseTests: XCTestCase {
_ = await store.send(.setExternalId(""))
}

func testSetExternalIdWithWhiteSpaces() async throws {
let initialState = INITIALIZED_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())

_ = await store.send(.setExternalId(""))
}

// MARK: - Set Phone number

@MainActor
Expand Down Expand Up @@ -233,6 +247,13 @@ class StateManagementEdgeCaseTests: XCTestCase {
_ = await store.send(.setPhoneNumber(""))
}

func testSetPhoneNumberWithWhiteSpaces() async throws {
let initialState = INITIALIZED_TEST_STATE()
let store = TestStore(initialState: initialState, reducer: KlaviyoReducer())

_ = await store.send(.setPhoneNumber(""))
}

// MARK: - Set Push Token

@MainActor
Expand Down

0 comments on commit adff271

Please sign in to comment.