Skip to content

Commit

Permalink
Add test for failing constructing email
Browse files Browse the repository at this point in the history
  • Loading branch information
pietbrauer committed Nov 4, 2015
1 parent 380ef3f commit f85ad3d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
7 changes: 0 additions & 7 deletions TrashCanKit/Repositories.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,4 @@ public enum RepositoryRouter: Router {
return "/repositories/\(userName)"
}
}

public var URLRequest: NSURLRequest? {
switch self {
case .ReadRepositories(_, _):
return request()
}
}
}
6 changes: 6 additions & 0 deletions TrashCanKit/TrashCanKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ public struct TrashCanKit {
configuration = config
}
}

internal extension Router {
internal var URLRequest: NSURLRequest? {
return request()
}
}
8 changes: 0 additions & 8 deletions TrashCanKit/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,11 @@ public extension TrashCanKit {

public enum UserRouter: Router {
case ReadAuthenticatedUser(Configuration)
case ReadUser(String, Configuration)
case ReadEmails(Configuration)

public var configuration: Configuration {
switch self {
case .ReadAuthenticatedUser(let config): return config
case .ReadUser(_, let config): return config
case .ReadEmails(let config): return config
}
}
Expand All @@ -94,8 +92,6 @@ public enum UserRouter: Router {
switch self {
case .ReadAuthenticatedUser:
return "user"
case .ReadUser(let username, _):
return "users/\(username)"
case .ReadEmails:
return "user/emails"
}
Expand All @@ -104,8 +100,4 @@ public enum UserRouter: Router {
public var params: [String: String] {
return [:]
}

public var URLRequest: NSURLRequest? {
return request()
}
}
8 changes: 8 additions & 0 deletions TrashCanKitTests/UserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ class UserTests: XCTestCase {
XCTAssertEqual(subject.type, "email")
}

func testConstructEmailFromEmptyJSON() {
let subject = Email(json: [:])
XCTAssertEqual(subject.isPrimary, false)
XCTAssertEqual(subject.isConfirmed, false)
XCTAssertEqual(subject.email, nil)
XCTAssertEqual(subject.type, nil)
}

func testMe() {
let tokenConfig = TokenConfiguration("123456", refreshToken: "7890")
stubRequest("GET", "https://bitbucket.org/api/2.0/user?access_token=123456").andReturn(200).withBody(TestHelper.loadJSONString("Me"))
Expand Down

0 comments on commit f85ad3d

Please sign in to comment.