in FBSDKLoginKit/FBSDKLoginKitTests/LoginCompletionTests.swift [717:829]
func testCreateProfileWithClaims() throws {
let factory = TestProfileFactory(stubbedProfile: SampleUserProfiles.createValid())
LoginURLCompleter.profileFactory = factory
let claim = try XCTUnwrap(
AuthenticationTokenClaims(
jti: "some_jti",
iss: "some_iss",
aud: "some_aud",
nonce: Values.nonce,
exp: 1234,
iat: 1234,
sub: "some_sub",
name: "some_name",
givenName: "first",
middleName: "middle",
familyName: "last",
email: "example@example.com",
picture: "www.facebook.com",
userFriends: ["123", "456"],
userBirthday: "01/01/1990",
userAgeRange: ["min": 21],
userHometown: ["id": "112724962075996", "name": "Martinez, California"],
userLocation: ["id": "110843418940484", "name": "Seattle, Washington"],
userGender: "male",
userLink: "facebook.com"
)
)
LoginURLCompleter.profile(with: claim)
XCTAssertEqual(
factory.capturedUserID,
claim.sub,
"Should request a profile with the claims sub as the user identifier"
)
XCTAssertEqual(
factory.capturedName,
claim.name,
"Should request a profile using the name from the claims"
)
XCTAssertEqual(
factory.capturedFirstName,
claim.givenName,
"Should request a profile using the first name from the claims"
)
XCTAssertEqual(
factory.capturedMiddleName,
claim.middleName,
"Should request a profile using the middle name from the claims"
)
XCTAssertEqual(
factory.capturedLastName,
claim.familyName,
"Should request a profile using the last name from the claims"
)
XCTAssertEqual(
factory.capturedImageURL?.absoluteString,
claim.picture,
"Should request an image URL from the claims"
)
XCTAssertEqual(
factory.capturedEmail,
claim.email,
"Should request a profile using the email from the claims"
)
XCTAssertEqual(
factory.capturedFriendIDs,
claim.userFriends,
"Should request a profile using the friend identifiers from the claims"
)
// @lint-ignore FBOBJCDISCOURAGEDFUNCTION
let formatter = DateFormatter()
formatter.dateFormat = "MM/dd/yyyy"
let capturedBirthday = try XCTUnwrap(factory.capturedBirthday)
XCTAssertEqual(
formatter.string(from: capturedBirthday),
claim.userBirthday,
"Should request a profile using the user birthday from the claims"
)
let rawAgeRange = try XCTUnwrap(claim.userAgeRange)
XCTAssertEqual(
factory.capturedAgeRange,
UserAgeRange(from: rawAgeRange),
"Should request a profile using the user age range from the claims"
)
let rawHometownLocation = try XCTUnwrap(claim.userHometown)
XCTAssertEqual(
factory.capturedHometown,
Location(from: rawHometownLocation),
"Should request a profile using the user hometown from the claims"
)
let rawUserLocation = try XCTUnwrap(claim.userLocation)
XCTAssertEqual(
factory.capturedLocation,
Location(from: rawUserLocation),
"Should request a profile using the user location from the claims"
)
XCTAssertEqual(
factory.capturedGender,
claim.userGender,
"Should request a profile using the gender from the claims"
)
let rawUserLink = try XCTUnwrap(claim.userLink)
XCTAssertEqual(
factory.capturedLinkURL,
URL(string: rawUserLink),
"Should request a profile using the link from the claims"
)
XCTAssertTrue(
factory.capturedIsLimited,
"Should request a profile with limited information"
)
}