Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
func testDeleteFolder() {
attempt {
let session = Session.nas
var response: JSONObject?
stub(session, "delete-folder") { expectation in
try! Folder.deleteFolder(session, folderID: "10396915")
.startWithCompletedExpectation(expectation) { value in
response = value
}
}
XCTAssertNotNil(response, "it should get a successful response")
}
}
func testDeleteFolder() {
attempt {
let session = Session.art
let request = try! FileNodeAPI.deleteFolder(session, folderID: "1")
XCTAssertEqual("/api/v1/folders/1", request.URL?.relativePath, "url matches")
XCTAssertEqual("DELETE", request.HTTPMethod, "it is a DELETE request")
}
}
func testNewFolder() {
attempt {
let session = Session.nas
let context = try session.filesManagedObjectContext()
assertDifference({ Folder.count(inContext: context) }, 1) {
self.stub(session, "add-folder") { expectation in
Folder.newFolder(session, folderID: "10119415", name: "Folder")
.startWithCompletedExpectation(expectation) { _ in }
}
guard let folder = try? Folder.findOne(withValue: "10119415", forKey: "parentFolderID", inContext: context) else {
XCTFail("Expected a folder")
return
}
XCTAssertEqual("Folder 7", folder.name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.