             result = response
         }
 
-
         expect(result?.error).toEventually(equal(TODOAPIClientError.NetworkError))
     }
 

            result = response
        }


        expect(result?.error).toEventually(equal(TODOAPIClientError.NetworkError))
    }


            result = response
        }

        expect(result?.error).toEventually(equal(TODOAPIClientError.UnknownError(code: 418)))
    }

    func testDeletesATask() {
        stubRequest("DELETE", "http://jsonplaceholder.typicode.com/todos/1")
            .andReturn(200)

        var result: Result<Void, TODOAPIClientError>?
        apiClient.deleteTaskById("1") { response in
            result = response
        }

        expect(result).toEventuallyNot(beNil())
    }

    func testReturnsItemNotFoundIfThereIsNoTaskWithIdTheAssociateId() {
        stubRequest("DELETE", "http://jsonplaceholder.typicode.com/todos/1")
            .andReturn(404)

        var result: Result<Void, TODOAPIClientError>?
        apiClient.deleteTaskById("1") { response in
            result = response
        }

        expect(result?.error).toEventually(equal(TODOAPIClientError.ItemNotFound))
    }

    func testReturnsNetworkErrorIfThereIsNoConnectionDeletingTask() {
        stubRequest("DELETE", "http://jsonplaceholder.typicode.com/todos/1")
            .andFailWithError(NSError.networkError())

        var result: Result<Void, TODOAPIClientError>?
        apiClient.deleteTaskById("1") { response in
            result = response
        }

        expect(result?.error).toEventually(equal(TODOAPIClientError.NetworkError))
    }

    func testReturnsUnknownErrorIfThereIsAnyErrorDeletingTask() {
        stubRequest("DELETE", "http://jsonplaceholder.typicode.com/todos/1")
            .andReturn(418)

        var result: Result<Void, TODOAPIClientError>?
        apiClient.deleteTaskById("1") { response in
            result = response
        }

        expect(result?.error).toEventually(equal(TODOAPIClientError.UnknownError(code: 418)))
    }
