Skip to content

Commit

Permalink
Added AutoID tests
Browse files Browse the repository at this point in the history
  • Loading branch information
1amageek committed May 24, 2019
1 parent 75230ec commit 80b2391
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions BallcapTests/DocumentTests.swift
Expand Up @@ -20,6 +20,13 @@ class DocumentTests: XCTestCase {
BallcapApp.configure(Firestore.firestore().document("version/1"))
}

func testDocumentAutoID() {
struct Model: Codable, Modelable, Equatable {}
let d: Document<Model> = Document()
XCTAssertEqual(d.documentReference.parent.path, "version/1/model")
XCTAssertEqual(d.documentReference.path, "version/1/model/\(d.id)")
}

func testDocumentID() {
struct Model: Codable, Modelable, Equatable {}
let d: Document<Model> = Document(id: "a")
Expand Down
10 changes: 10 additions & 0 deletions BallcapTests/ObjectTests.swift
Expand Up @@ -19,6 +19,16 @@ class ObjectTests: XCTestCase {
BallcapApp.configure(Firestore.firestore().document("version/1"))
}

func testObjectAutoID() {
class Obj: Object, DataRepresentable {
struct Model: Modelable & Codable { }
var data: Model?
}
let o: Obj = Obj()
XCTAssertEqual(o.documentReference.parent.path, "version/1/obj")
XCTAssertEqual(o.documentReference.path, "version/1/obj/\(o.id)")
}

func testObjectID() {
class Obj: Object, DataRepresentable {
struct Model: Modelable & Codable { }
Expand Down

0 comments on commit 80b2391

Please sign in to comment.