Skip to content

Commit

Permalink
Add tests for KeyPath description and appending operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerluan committed May 28, 2022
1 parent f53f53d commit 59039f0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/KeyPathTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,22 @@ final class KeyPathTests : XCTestCase {
let keyPath = KeyPath(path)
XCTAssertEqual(keyPath.path, path)
}

func test_description_whenSegmentIsEmpty_shouldReturnEmptyString() {
XCTAssertEqual(KeyPath(""), "")
}

func test_description_whenSegmentHasOneElement_shouldReturnThatElement() {
XCTAssertEqual(KeyPath("element"), "element")
}

func test_description_whenSegmentHasTwoElements_shouldReturnStringSeparatedByPeriod() {
XCTAssertEqual(KeyPath("my.name"), "my.name")
}

func test_pathAppending_whenPathIsValid_shouldReturnAppendedPathsUsingPeriod() {
let lhs = "this.is.path.start"
let rhs = "this.is.path.end"
XCTAssertEqual(KeyPath(lhs) + KeyPath(rhs), "this.is.path.start.this.is.path.end")
}
}

0 comments on commit 59039f0

Please sign in to comment.