Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shopify_iossdk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
shopify_iossdk
Commits
ffb8db1c
Commit
ffb8db1c
authored
Jul 20, 2016
by
Brent Gulanowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests for changes to customer and address client methods.
parent
da1318c5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
46 deletions
+60
-46
BUYClient+CustomerTests.m
...le Buy SDK/Mobile Buy SDK Tests/BUYClient+CustomerTests.m
+12
-12
BUYClient+RoutingTests.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClient+RoutingTests.m
+16
-18
BUYClientTest.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
+32
-16
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClient+CustomerTests.m
View file @
ffb8db1c
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerLogin"
useMocks
:[
self
shouldUseMocks
]];
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerLogin"
useMocks
:[
self
shouldUseMocks
]];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
loginCustomerWithCredentials
:[
self
credentialsForLogin
]
callback
:
^
(
BUYCustomer
*
customer
,
NSString
*
token
,
NSError
*
error
)
{
[
self
.
client
loginCustomerWithCredentials
:[
self
credentialsForLogin
]
callback
:
^
(
BUYCustomer
*
customer
,
BUYCustomerToken
*
token
,
NSError
*
error
)
{
XCTAssertNil
(
error
);
XCTAssertNil
(
error
);
XCTAssertNotNil
(
customer
);
XCTAssertNotNil
(
customer
);
...
@@ -87,7 +87,7 @@
...
@@ -87,7 +87,7 @@
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerDuplicateEmail"
useMocks
:[
self
shouldUseMocks
]];
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerDuplicateEmail"
useMocks
:[
self
shouldUseMocks
]];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
createCustomerWithCredentials
:[
self
credentialsForCreation
]
callback
:
^
(
BUYCustomer
*
customer
,
NSString
*
token
,
NSError
*
error
)
{
[
self
.
client
createCustomerWithCredentials
:[
self
credentialsForCreation
]
callback
:
^
(
BUYCustomer
*
customer
,
BUYCustomerToken
*
token
,
NSError
*
error
)
{
XCTAssertNil
(
customer
);
XCTAssertNil
(
customer
);
XCTAssertNotNil
(
error
);
XCTAssertNotNil
(
error
);
...
@@ -114,7 +114,7 @@
...
@@ -114,7 +114,7 @@
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerInvalidEmailPassword"
useMocks
:[
self
shouldUseMocks
]];
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerInvalidEmailPassword"
useMocks
:[
self
shouldUseMocks
]];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
createCustomerWithCredentials
:[
self
credentialsForFailure
]
callback
:
^
(
BUYCustomer
*
customer
,
NSString
*
token
,
NSError
*
error
)
{
[
self
.
client
createCustomerWithCredentials
:[
self
credentialsForFailure
]
callback
:
^
(
BUYCustomer
*
customer
,
BUYCustomerToken
*
token
,
NSError
*
error
)
{
XCTAssertNil
(
customer
);
XCTAssertNil
(
customer
);
XCTAssertNotNil
(
error
);
XCTAssertNotNil
(
error
);
...
@@ -149,7 +149,7 @@
...
@@ -149,7 +149,7 @@
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerLogout"
useMocks
:[
self
shouldUseMocks
]];
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerLogout"
useMocks
:[
self
shouldUseMocks
]];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
logoutCustomer
ID
:
self
.
customer
.
identifier
.
stringValue
c
allback
:
^
(
BUYStatus
status
,
NSError
*
_Nullable
error
)
{
[
self
.
client
logoutCustomer
C
allback
:
^
(
BUYStatus
status
,
NSError
*
_Nullable
error
)
{
XCTAssertNil
(
error
);
XCTAssertNil
(
error
);
XCTAssertEqual
(
status
,
204
);
XCTAssertEqual
(
status
,
204
);
...
@@ -167,7 +167,7 @@
...
@@ -167,7 +167,7 @@
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerGetOrders"
useMocks
:[
self
shouldUseMocks
]];
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerGetOrders"
useMocks
:[
self
shouldUseMocks
]];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
getOrdersForCustomer
WithID
:
self
.
customer
.
identifier
.
stringValue
c
allback
:
^
(
NSArray
<
BUYOrder
*>
*
_Nullable
orders
,
NSError
*
_Nullable
error
)
{
[
self
.
client
getOrdersForCustomer
C
allback
:
^
(
NSArray
<
BUYOrder
*>
*
_Nullable
orders
,
NSError
*
_Nullable
error
)
{
XCTAssertNotNil
(
orders
);
XCTAssertNotNil
(
orders
);
XCTAssertNil
(
error
);
XCTAssertNil
(
error
);
...
@@ -186,7 +186,7 @@
...
@@ -186,7 +186,7 @@
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerGetOrder"
useMocks
:[
self
shouldUseMocks
]];
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerGetOrder"
useMocks
:[
self
shouldUseMocks
]];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
getOrderWithID
:
self
.
customerOrderIDs
.
firstObject
c
ustomerID
:
self
.
customer
.
identifier
.
stringValue
c
allback
:^
(
BUYOrder
*
_Nullable
order
,
NSError
*
_Nullable
error
)
{
[
self
.
client
getOrderWithID
:
self
.
customerOrderIDs
.
firstObject
callback
:
^
(
BUYOrder
*
_Nullable
order
,
NSError
*
_Nullable
error
)
{
XCTAssertNil
(
error
);
XCTAssertNil
(
error
);
XCTAssertTrue
([
order
isKindOfClass
:[
BUYOrder
class
]]);
XCTAssertTrue
([
order
isKindOfClass
:[
BUYOrder
class
]]);
...
@@ -208,7 +208,7 @@
...
@@ -208,7 +208,7 @@
BUYAccountCredentialItem
*
email
=
[
BUYAccountCredentialItem
itemWithEmail
:
self
.
customerEmail
];
BUYAccountCredentialItem
*
email
=
[
BUYAccountCredentialItem
itemWithEmail
:
self
.
customerEmail
];
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:@[
email
]];
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:@[
email
]];
[
self
.
client
updateCustomerWithCredentials
:
credentials
c
ustomerID
:
self
.
customer
.
identifier
.
stringValue
c
allback
:^
(
BUYCustomer
*
customer
,
NSError
*
error
)
{
[
self
.
client
updateCustomerWithCredentials
:
credentials
callback
:
^
(
BUYCustomer
*
customer
,
NSError
*
error
)
{
XCTAssertNil
(
error
);
XCTAssertNil
(
error
);
XCTAssertNotNil
(
customer
);
XCTAssertNotNil
(
customer
);
...
@@ -231,7 +231,7 @@
...
@@ -231,7 +231,7 @@
}];
}];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
getAddresses
ForCustomerID
:
self
.
customer
.
identifier
.
stringValue
c
allback
:
^
(
NSArray
<
BUYAddress
*>
*
_Nullable
addresses
,
NSError
*
_Nullable
error
)
{
[
self
.
client
getAddresses
C
allback
:
^
(
NSArray
<
BUYAddress
*>
*
_Nullable
addresses
,
NSError
*
_Nullable
error
)
{
XCTAssertNotNil
(
addresses
);
XCTAssertNotNil
(
addresses
);
XCTAssertTrue
(
addresses
.
count
>
0
);
XCTAssertTrue
(
addresses
.
count
>
0
);
...
@@ -264,7 +264,7 @@
...
@@ -264,7 +264,7 @@
BUYAddress
*
address
=
[
self
address
];
BUYAddress
*
address
=
[
self
address
];
[
self
.
client
createAddress
:
address
c
ustomerID
:
self
.
customer
.
identifier
.
stringValue
c
allback
:^
(
BUYAddress
*
_Nullable
returnedAddress
,
NSError
*
_Nullable
error
)
{
[
self
.
client
createAddress
:
address
callback
:
^
(
BUYAddress
*
_Nullable
returnedAddress
,
NSError
*
_Nullable
error
)
{
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerLogin"
useMocks
:[
self
shouldUseMocks
]];
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerLogin"
useMocks
:[
self
shouldUseMocks
]];
...
@@ -299,7 +299,7 @@
...
@@ -299,7 +299,7 @@
}];
}];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
getAddressWithID
:
self
.
createdAddress
.
identifier
c
ustomerID
:
self
.
customer
.
identifier
.
stringValue
c
allback
:^
(
BUYAddress
*
_Nullable
address
,
NSError
*
_Nullable
error
)
{
[
self
.
client
getAddressWithID
:
self
.
createdAddress
.
identifier
callback
:
^
(
BUYAddress
*
_Nullable
address
,
NSError
*
_Nullable
error
)
{
XCTAssertNotNil
(
address
);
XCTAssertNotNil
(
address
);
XCTAssertNil
(
error
);
XCTAssertNil
(
error
);
...
@@ -323,7 +323,7 @@
...
@@ -323,7 +323,7 @@
BUYAddress
*
modifiedAddress
=
[
self
addressByModyfyingAddress
:
self
.
createdAddress
];
BUYAddress
*
modifiedAddress
=
[
self
addressByModyfyingAddress
:
self
.
createdAddress
];
[
self
.
client
updateAddress
:
modifiedAddress
c
ustomerID
:
self
.
customer
.
identifier
.
stringValue
c
allback
:^
(
BUYAddress
*
_Nullable
returnedAddress
,
NSError
*
_Nullable
error
)
{
[
self
.
client
updateAddress
:
modifiedAddress
callback
:
^
(
BUYAddress
*
_Nullable
returnedAddress
,
NSError
*
_Nullable
error
)
{
XCTAssertNotNil
(
returnedAddress
);
XCTAssertNotNil
(
returnedAddress
);
XCTAssertNil
(
error
);
XCTAssertNil
(
error
);
...
@@ -353,7 +353,7 @@
...
@@ -353,7 +353,7 @@
}];
}];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
deleteAddressWithID
:
self
.
createdAddress
.
identifier
c
ustomerID
:
self
.
customer
.
identifier
.
stringValue
c
allback
:^
(
BUYStatus
status
,
NSError
*
_Nullable
error
)
{
[
self
.
client
deleteAddressWithID
:
self
.
createdAddress
.
identifier
callback
:
^
(
BUYStatus
status
,
NSError
*
_Nullable
error
)
{
XCTAssertEqual
(
status
,
204
);
XCTAssertEqual
(
status
,
204
);
XCTAssertNil
(
error
);
XCTAssertNil
(
error
);
...
...
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClient+RoutingTests.m
View file @
ffb8db1c
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#import <XCTest/XCTest.h>
#import <XCTest/XCTest.h>
#import "BUYClient+Routing.h"
#import "BUYClient+Routing.h"
#import "BUYCustomerToken.h"
@interface
BUYClient_RoutingTests
:
XCTestCase
@interface
BUYClient_RoutingTests
:
XCTestCase
...
@@ -42,13 +43,14 @@
...
@@ -42,13 +43,14 @@
[
super
setUp
];
[
super
setUp
];
self
.
client
=
[[
BUYClient
alloc
]
initWithShopDomain
:
@"_DOMAIN_"
apiKey
:
@"_API_KEY_"
appId
:
@"_APP_ID_"
];
self
.
client
=
[[
BUYClient
alloc
]
initWithShopDomain
:
@"_DOMAIN_"
apiKey
:
@"_API_KEY_"
appId
:
@"_APP_ID_"
];
self
.
client
.
customerToken
=
[[
BUYCustomerToken
alloc
]
initWithCustomerID
:
@1
accessToken
:
@"token"
expiry
:
[
NSDate
date
]];
}
}
#pragma mark - Test Routes -
#pragma mark - Test Routes -
-
(
void
)
testRoutes
-
(
void
)
testRoutes
{
{
NSString
*
identifier
=
@"
_ID_
"
;
NSString
*
identifier
=
@"
1
"
;
NSString
*
token
=
@"_TOKEN_"
;
NSString
*
token
=
@"_TOKEN_"
;
NSDictionary
*
parameters
=
@{
@"param"
:
@"value"
};
NSDictionary
*
parameters
=
@{
@"param"
:
@"value"
};
...
@@ -122,41 +124,37 @@
...
@@ -122,41 +124,37 @@
@"https://_DOMAIN_/api/customers/recover.json"
@"https://_DOMAIN_/api/customers/recover.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCustomersOrders
WithID
:
identifier
].
absoluteString
,
[
self
.
client
urlForCustomersOrders
].
absoluteString
,
@"https://_DOMAIN_/api/customers/
_ID_
/orders.json"
@"https://_DOMAIN_/api/customers/
1
/orders.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCustomersOrdersWith
ID
:
identifier
o
rderID
:
@99
].
absoluteString
,
[
self
.
client
urlForCustomersOrdersWith
O
rderID
:
@99
].
absoluteString
,
@"https://_DOMAIN_/api/customers/
_ID_
/orders/99.json"
@"https://_DOMAIN_/api/customers/
1
/orders/99.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCustomersWithID
:
identifier
].
absoluteString
,
[
self
.
client
urlForCustomersWithID
:
identifier
].
absoluteString
,
@"https://_DOMAIN_/api/customers/
_ID_
.json"
@"https://_DOMAIN_/api/customers/
1
.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCustomersActivationWithID
:
identifier
parameters
:
parameters
].
absoluteString
,
[
self
.
client
urlForCustomersActivationWithID
:
identifier
parameters
:
parameters
].
absoluteString
,
@"https://_DOMAIN_/api/customers/
_ID_
/activate.json?param=value"
@"https://_DOMAIN_/api/customers/
1
/activate.json?param=value"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCustomersTokenWithID
:
identifier
].
absoluteString
,
[
self
.
client
urlForCustomersTokenRenewal
].
absoluteString
,
@"https://_DOMAIN_/api/customers/_ID_/customer_token.json"
@"https://_DOMAIN_/api/customers/1/customer_token/renew.json"
);
XCTAssertEqualObjects
(
[
self
.
client
urlForCustomersTokenRenewalWithID
:
identifier
].
absoluteString
,
@"https://_DOMAIN_/api/customers/_ID_/customer_token/renew.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCustomersPasswordResetWithID
:
identifier
parameters
:
parameters
].
absoluteString
,
[
self
.
client
urlForCustomersPasswordResetWithID
:
identifier
parameters
:
parameters
].
absoluteString
,
@"https://_DOMAIN_/api/customers/
_ID_
/reset.json?param=value"
@"https://_DOMAIN_/api/customers/
1
/reset.json?param=value"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCustomersAddresses
WithID
:
identifier
].
absoluteString
,
[
self
.
client
urlForCustomersAddresses
].
absoluteString
,
@"https://_DOMAIN_/api/customers/
_ID_
/addresses.json"
@"https://_DOMAIN_/api/customers/
1
/addresses.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCustomersAddressWith
ID
:
identifier
a
ddressID
:
@999
].
absoluteString
,
[
self
.
client
urlForCustomersAddressWith
A
ddressID
:
@999
].
absoluteString
,
@"https://_DOMAIN_/api/customers/
_ID_
/addresses/999.json"
@"https://_DOMAIN_/api/customers/
1
/addresses/999.json"
);
);
}
}
...
...
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
View file @
ffb8db1c
...
@@ -38,8 +38,6 @@
...
@@ -38,8 +38,6 @@
#import "BUYApplePayTestToken.h"
#import "BUYApplePayTestToken.h"
#import "BUYRequestOperation.h"
#import "BUYRequestOperation.h"
NSString
*
const
BUYFakeCustomerToken
=
@"dsfasdgafdg"
;
@interface
BUYClient_Test
:
BUYClient
@interface
BUYClient_Test
:
BUYClient
@end
@end
...
@@ -58,6 +56,23 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
...
@@ -58,6 +56,23 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
@implementation
BUYClientTest
@implementation
BUYClientTest
-
(
void
)
setUp
{
[
super
setUp
];
self
.
client
.
customerToken
=
[
self
customerTokenForTesting
];
}
-
(
void
)
tearDown
{
self
.
client
.
customerToken
=
nil
;
[
super
tearDown
];
}
-
(
BUYCustomerToken
*
)
customerTokenForTesting
{
return
[[
BUYCustomerToken
alloc
]
initWithCustomerID
:
@1
accessToken
:
@""
expiry
:
[
NSDate
dateWithTimeIntervalSinceNow
:
3600
]];
}
-
(
void
)
setupClient
-
(
void
)
setupClient
{
{
self
.
shopDomain
=
BUYShopDomain_Placeholder
;
self
.
shopDomain
=
BUYShopDomain_Placeholder
;
...
@@ -211,7 +226,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
...
@@ -211,7 +226,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
];
];
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:
items
];
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:
items
];
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
createCustomerWithCredentials
:
credentials
callback
:
^
(
BUYCustomer
*
customer
,
NSString
*
token
,
NSError
*
error
)
{
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
createCustomerWithCredentials
:
credentials
callback
:
^
(
BUYCustomer
*
customer
,
BUYCustomerToken
*
token
,
NSError
*
error
)
{
}];
}];
...
@@ -239,7 +254,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
...
@@ -239,7 +254,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
[
BUYAccountCredentialItem
itemWithPassword
:
@"password"
],
[
BUYAccountCredentialItem
itemWithPassword
:
@"password"
],
];
];
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:
items
];
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:
items
];
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
loginCustomerWithCredentials
:
credentials
callback
:
^
(
BUYCustomer
*
customer
,
NSString
*
token
,
NSError
*
error
)
{
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
loginCustomerWithCredentials
:
credentials
callback
:
^
(
BUYCustomer
*
customer
,
BUYCustomerToken
*
token
,
NSError
*
error
)
{
}];
}];
...
@@ -260,28 +275,28 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
...
@@ -260,28 +275,28 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
-
(
void
)
testGetCustomerURL
-
(
void
)
testGetCustomerURL
{
{
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
getCustomer
WithID
:
@""
c
allback
:
^
(
BUYCustomer
*
customer
,
NSError
*
error
)
{
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
getCustomer
C
allback
:
^
(
BUYCustomer
*
customer
,
NSError
*
error
)
{
}];
}];
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
scheme
,
@"https"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
scheme
,
@"https"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
path
,
@"/api/customers.json"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
path
,
@"/api/customers
/1
.json"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
HTTPMethod
,
@"GET"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
HTTPMethod
,
@"GET"
);
XCTAssertEqualObjects
(
self
.
client
.
customerToken
,
task
.
originalRequest
.
allHTTPHeaderFields
[
BUYClientCustomerAccessToken
]);
XCTAssertEqualObjects
(
self
.
client
.
customerToken
.
accessToken
,
task
.
originalRequest
.
allHTTPHeaderFields
[
BUYClientCustomerAccessToken
]);
}
}
-
(
void
)
testGetOrdersForCustomerURL
-
(
void
)
testGetOrdersForCustomerURL
{
{
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
getOrdersForCustomer
WithID
:
@"99"
c
allback
:
^
(
NSArray
<
BUYOrder
*>
*
orders
,
NSError
*
error
)
{
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
getOrdersForCustomer
C
allback
:
^
(
NSArray
<
BUYOrder
*>
*
orders
,
NSError
*
error
)
{
}];
}];
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
scheme
,
@"https"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
scheme
,
@"https"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
path
,
@"/api/customers/
99
/orders.json"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
path
,
@"/api/customers/
1
/orders.json"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
HTTPMethod
,
@"GET"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
HTTPMethod
,
@"GET"
);
XCTAssertEqualObjects
(
self
.
client
.
customerToken
,
task
.
originalRequest
.
allHTTPHeaderFields
[
BUYClientCustomerAccessToken
]);
XCTAssertEqualObjects
(
self
.
client
.
customerToken
.
accessToken
,
task
.
originalRequest
.
allHTTPHeaderFields
[
BUYClientCustomerAccessToken
]);
}
}
-
(
void
)
testCustomerRecovery
-
(
void
)
testCustomerRecovery
...
@@ -307,11 +322,12 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
...
@@ -307,11 +322,12 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
{
{
self
.
client
.
customerToken
=
nil
;
self
.
client
.
customerToken
=
nil
;
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
renewCustomerToken
WithID
:
@""
c
allback
:
^
(
NSString
*
token
,
NSError
*
error
)
{}];
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
renewCustomerToken
C
allback
:
^
(
NSString
*
token
,
NSError
*
error
)
{}];
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
;
task
=
(
BUYRequestOperation
*
)[
self
.
client
renewCustomerTokenWithID
:
@"1"
callback
:
^
(
NSString
*
token
,
NSError
*
error
)
{
self
.
client
.
customerToken
=
[[
BUYCustomerToken
alloc
]
initWithCustomerID
:
@1
accessToken
:
@"fake_token"
expiry
:
[
NSDate
dateWithTimeIntervalSinceNow
:
3600
]];
task
=
(
BUYRequestOperation
*
)[
self
.
client
renewCustomerTokenCallback
:
^
(
NSString
*
token
,
NSError
*
error
)
{
}];
}];
...
@@ -328,7 +344,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
...
@@ -328,7 +344,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:
items
];
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:
items
];
NSString
*
customerID
=
@"12345"
;
NSString
*
customerID
=
@"12345"
;
NSString
*
token
=
@"12345"
;
NSString
*
token
=
@"12345"
;
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
activateCustomerWithCredentials
:
credentials
customerID
:
customerID
token
:
token
callback
:^
(
BUYCustomer
*
customer
,
NSString
*
token
,
NSError
*
error
)
{
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
activateCustomerWithCredentials
:
credentials
customerID
:
customerID
token
:
token
callback
:^
(
BUYCustomer
*
customer
,
BUYCustomerToken
*
token
,
NSError
*
error
)
{
}];
}];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment