diff --git a/Tests/ParseSwiftTests/ParseObjectTests.swift b/Tests/ParseSwiftTests/ParseObjectTests.swift index ee3d7be41..3399c5288 100644 --- a/Tests/ParseSwiftTests/ParseObjectTests.swift +++ b/Tests/ParseSwiftTests/ParseObjectTests.swift @@ -634,6 +634,13 @@ class ParseObjectTests: XCTestCase { // swiftlint:disable:this type_body_length return MockURLResponse(data: encoded, statusCode: 200, delay: 0.0) } do { + score.score = 12 + let command = try score.saveCommand() + XCTAssertNotNil(command) + XCTAssertEqual(command.path.urlComponent, "/classes/GameScore/yarr") + XCTAssertEqual(command.method, API.Method.PUT) + XCTAssertNil(command.body?.player) + XCTAssertEqual(command.body?.score, 12) let saved = try score.save() guard let savedUpdatedAt = saved.updatedAt else { XCTFail("Should unwrap dates") diff --git a/Tests/ParseSwiftTests/ParseUserTests.swift b/Tests/ParseSwiftTests/ParseUserTests.swift index 9f45982d5..36e8ab425 100644 --- a/Tests/ParseSwiftTests/ParseUserTests.swift +++ b/Tests/ParseSwiftTests/ParseUserTests.swift @@ -777,6 +777,52 @@ class ParseUserTests: XCTestCase { // swiftlint:disable:this type_body_length XCTAssertEqual(command.body?.customKey, "hello") } + func testSignupCommandAndFutureSave() throws { + var loginResponse = LoginSignupResponse() + loginResponse.email = nil + + MockURLProtocol.mockRequests { _ in + do { + let encoded = try loginResponse.getEncoder().encode(loginResponse, skipKeys: .none) + return MockURLResponse(data: encoded, statusCode: 200, delay: 0.0) + } catch { + return nil + } + } + do { + var user = User() + user.username = loginUserName + user.password = loginPassword + user.email = "test@example.com" + user.customKey = "blah" + let signedUp = try user.signup() + XCTAssertNotNil(signedUp) + XCTAssertNotNil(signedUp.createdAt) + XCTAssertNotNil(signedUp.updatedAt) + XCTAssertEqual(signedUp.email, "test@example.com") + XCTAssertNotNil(signedUp.username) + XCTAssertNil(signedUp.password) + XCTAssertNotNil(signedUp.objectId) + XCTAssertNotNil(signedUp.sessionToken) + XCTAssertNotNil(signedUp.customKey) + XCTAssertNil(signedUp.ACL) + + var current = User.current + current?.customKey = "blah2" + let command = try current?.saveCommand() + XCTAssertNotNil(command) + XCTAssertEqual(command?.path.urlComponent, "/users/yarr") + XCTAssertEqual(command?.method, API.Method.PUT) + XCTAssertNil(command?.body?.email) + XCTAssertNil(command?.body?.username) + XCTAssertNil(command?.body?.password) + XCTAssertEqual(command?.body?.customKey, "blah2") + + } catch { + XCTFail(error.localizedDescription) + } + } + func testUserSignUp() { let loginResponse = LoginSignupResponse()