Commit 9ae0dc11 by Dima Bart

Clean up client tests: remove nullability, reduce indentation.

parent 25fc9987
...@@ -327,15 +327,16 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -327,15 +327,16 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testCustomerCreationURL - (void)testCustomerCreationURL
{ {
BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:@[ NSArray *items = @[
[BUYAccountCredentialItem itemWithFirstName:@"michael"], [BUYAccountCredentialItem itemWithFirstName:@"michael"],
[BUYAccountCredentialItem itemWithLastName:@"scott"], [BUYAccountCredentialItem itemWithLastName:@"scott"],
[BUYAccountCredentialItem itemWithEmail:@"fake@example.com"], [BUYAccountCredentialItem itemWithEmail:@"fake@example.com"],
[BUYAccountCredentialItem itemWithPassword:@"password"], [BUYAccountCredentialItem itemWithPassword:@"password"],
[BUYAccountCredentialItem itemWithPasswordConfirmation:@"password"], [BUYAccountCredentialItem itemWithPasswordConfirmation:@"password"],
]]; ];
BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:items];
NSURLSessionDataTask *task = [self.client createCustomerWithCredentials:credentials callback:^(BUYCustomer * _Nullable customer, NSString * _Nullable token, NSError * _Nullable error) {
NSURLSessionDataTask *task = [self.client createCustomerWithCredentials:credentials callback:^(BUYCustomer *customer, NSString *token, NSError *error) {
}]; }];
...@@ -359,11 +360,12 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -359,11 +360,12 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testLoginCustomerURL - (void)testLoginCustomerURL
{ {
BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:@[ NSArray *items = @[
[BUYAccountCredentialItem itemWithEmail:@"fake@example.com"], [BUYAccountCredentialItem itemWithEmail:@"fake@example.com"],
[BUYAccountCredentialItem itemWithPassword:@"password"], [BUYAccountCredentialItem itemWithPassword:@"password"],
]]; ];
NSURLSessionDataTask *task = [self.client loginCustomerWithCredentials:credentials callback:^(BUYCustomer * _Nullable customer, NSString * _Nullable token, NSError * _Nullable error) { BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:items];
NSURLSessionDataTask *task = [self.client loginCustomerWithCredentials:credentials callback:^(BUYCustomer *customer, NSString *token, NSError *error) {
}]; }];
...@@ -384,7 +386,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -384,7 +386,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testGetCustomerURL - (void)testGetCustomerURL
{ {
NSURLSessionDataTask *task = [self.client getCustomerWithID:@"" callback:^(BUYCustomer * _Nullable customer, NSError * _Nullable error) { NSURLSessionDataTask *task = [self.client getCustomerWithID:@"" callback:^(BUYCustomer *customer, NSError *error) {
}]; }];
...@@ -397,7 +399,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -397,7 +399,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testGetOrdersForCustomerURL - (void)testGetOrdersForCustomerURL
{ {
NSURLSessionDataTask *task = [self.client getOrdersForCustomerWithCallback:^(NSArray<BUYOrder *> * _Nullable orders, NSError * _Nullable error) { NSURLSessionDataTask *task = [self.client getOrdersForCustomerWithCallback:^(NSArray<BUYOrder *> *orders, NSError *error) {
}]; }];
...@@ -435,7 +437,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -435,7 +437,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
XCTAssertNil(task); // task should be nil if no customer token was set on the client XCTAssertNil(task); // task should be nil if no customer token was set on the client
self.client.customerToken = BUYFakeCustomerToken; self.client.customerToken = BUYFakeCustomerToken;
task = [self.client renewCustomerTokenWithID:@"1" callback:^(NSString * _Nullable token, NSError * _Nullable error) { task = [self.client renewCustomerTokenWithID:@"1" callback:^(NSString *token, NSError *error) {
}]; }];
...@@ -446,14 +448,14 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -446,14 +448,14 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testCustomerActivation - (void)testCustomerActivation
{ {
NSArray *items = @[
BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:@[ [BUYAccountCredentialItem itemWithPassword:@"12345"],
[BUYAccountCredentialItem itemWithPassword:@"12345"], [BUYAccountCredentialItem itemWithPasswordConfirmation:@"12345"],
[BUYAccountCredentialItem itemWithPasswordConfirmation:@"12345"], ];
]]; BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:items];
NSString *customerID = @"12345"; NSString *customerID = @"12345";
NSString *customerToken = @"12345"; NSString *customerToken = @"12345";
NSURLSessionDataTask *task = [self.client activateCustomerWithCredentials:credentials customerID:customerID customerToken:customerToken callback:^(BUYCustomer * _Nullable customer, NSString * _Nullable token, NSError * _Nullable error) { NSURLSessionDataTask *task = [self.client activateCustomerWithCredentials:credentials customerID:customerID customerToken:customerToken callback:^(BUYCustomer *customer, NSString *token, NSError *error) {
}]; }];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment