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
6a27c7c2
Commit
6a27c7c2
authored
May 19, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusts tests for aggregate complete checkout and shipping rate APIs.
parent
86047b7a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
40 deletions
+29
-40
BUYClientTest.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
+0
-13
BUYIntegrationTest.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYIntegrationTest.m
+20
-22
BUYClient+Checkout.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.m
+9
-1
BUYCheckoutOperation.m
... Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.m
+0
-4
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
View file @
6a27c7c2
...
...
@@ -184,19 +184,6 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
XCTAssertEqual
(
BUYStatusComplete
,
status
);
}
-
(
void
)
testCheckoutWithApplePayToken
{
id
<
BUYPaymentToken
>
token
=
[[
BUYApplePayToken
alloc
]
initWithPaymentToken
:[
BUYApplePayTestToken
validToken
]];
XCTAssertThrows
(
[
self
.
client
completeCheckout
:[
BUYCheckout
new
]
paymentToken
:
token
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{}]
);
BUYCheckout
*
checkout
=
[[
BUYCheckout
alloc
]
initWithModelManager
:
self
.
client
.
modelManager
JSONDictionary
:@{
@"token"
:
@"abcdef"
,
@"payment_due"
:
@0
}];
XCTAssertNoThrow
(
[
self
.
client
completeCheckout
:
checkout
paymentToken
:
nil
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{}]
);
}
-
(
void
)
testQueryItemsConversion
{
NSDictionary
*
dictionary
=
@{
@"collection_id"
:
@"1"
,
@"limit"
:
@"25"
,
@"page"
:
@"1"
,
@"sort_by"
:
@"collection-default"
};
...
...
Mobile Buy SDK/Mobile Buy SDK Tests/BUYIntegrationTest.m
View file @
6a27c7c2
...
...
@@ -31,6 +31,7 @@
#import "BUYTestConstants.h"
#import "BUYCheckout.h"
#import "BUYClientTestBase.h"
#import "BUYClient+Routing.h"
#import <OHHTTPStubs/OHHTTPStubs.h>
#import "OHHTTPStubsResponse+Helpers.h"
...
...
@@ -167,33 +168,20 @@
}
withStubResponse
:
^
OHHTTPStubsResponse
*
_Nonnull
(
NSURLRequest
*
_Nonnull
request
)
{
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testCheckoutFlowUsingCreditCard_2"
];
}];
__block
BUYStatus
shippingStatus
=
BUYStatusUnknown
;
do
{
NSLog
(
@"Fetching shipping rates..."
);
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
getShippingRatesForCheckout
:
_checkout
completion
:
^
(
NSArray
*
returnedShippingRates
,
BUYStatus
status
,
NSError
*
error
)
{
[
self
.
client
getShippingRatesForCheckout
:
_checkout
completion
:
^
(
NSArray
*
shippingRates
,
BUYStatus
status
,
NSError
*
error
)
{
XCTAssertNil
(
error
);
shippingStatus
=
status
;
if
(
shippingStatus
==
BUYStatusComplete
)
{
XCTAssertNotNil
(
returnedShippingRates
);
_shippingRates
=
returnedShippingRates
;
}
[
expectation
fulfill
];
}];
XCTAssertEqual
(
status
,
BUYStatusComplete
);
[
self
waitForExpectationsWithTimeout
:
10
handler
:
^
(
NSError
*
error
)
{
XCTAssertNil
(
error
);
}];
XCTAssertNotNil
(
shippingRates
);
XCTAssertTrue
([
shippingRates
count
]
>
0
);
if
(
shippingStatus
==
BUYStatusProcessing
)
{
[
NSThread
sleepForTimeInterval
:
0
.
5
f
];
}
}
while
(
shippingStatus
==
BUYStatusProcessing
);
_shippingRates
=
shippingRates
;
[
expectation
fulfill
];
}];
XCTAssertTrue
([
_shippingRates
count
]
>
0
);
XCTAssertEqual
(
shippingStatus
,
BUYStatusComplete
);
[
self
waitForExpectationsWithTimeout
:
10
.
0
handler
:
nil
];
}
-
(
void
)
updateCheckout
...
...
@@ -265,7 +253,17 @@
[
OHHTTPStubs
stubRequestsPassingTest
:
^
BOOL
(
NSURLRequest
*
_Nonnull
request
)
{
return
[
self
shouldUseMocks
];
}
withStubResponse
:
^
OHHTTPStubsResponse
*
_Nonnull
(
NSURLRequest
*
_Nonnull
request
)
{
NSString
*
path
=
request
.
URL
.
absoluteString
.
lastPathComponent
;
if
([
path
isEqualToString
:[
self
.
client
urlForCheckoutsCompletionWithToken
:
_checkout
.
token
].
lastPathComponent
])
{
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testCheckoutFlowUsingCreditCard_5"
];
}
else
if
([
path
isEqualToString
:[
self
.
client
urlForCheckoutsProcessingWithToken
:
_checkout
.
token
].
lastPathComponent
])
{
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testCheckoutFlowUsingCreditCard_14"
];
}
else
if
([
path
isEqualToString
:[
self
.
client
urlForCheckoutsWithToken
:
_checkout
.
token
].
lastPathComponent
])
{
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testCheckoutFlowUsingCreditCard_15"
];
}
return
[
OHHTTPStubsResponse
responseWithData
:[
NSData
new
]
statusCode
:
500
headers
:
nil
];;
}];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
...
...
@@ -283,7 +281,7 @@
[
self
confirmCreditCard
];
}];
[
self
waitForExpectationsWithTimeout
:
10
handler
:
^
(
NSError
*
error
)
{
[
self
waitForExpectationsWithTimeout
:
10
000
handler
:
^
(
NSError
*
error
)
{
XCTAssertNil
(
error
);
}];
}
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.m
View file @
6a27c7c2
...
...
@@ -27,6 +27,7 @@
#import "BUYClient+Checkout.h"
#import "BUYClient+Internal.h"
#import "BUYClient+Routing.h"
#import "BUYRequestOperation.h"
#import "BUYCheckoutOperation.h"
#import "BUYAddress.h"
#import "BUYCheckout.h"
...
...
@@ -226,7 +227,7 @@
@"checkout"
:
@""
,
}];
return
[
self
getRequestForURL
:
route
completionHandler
:
^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
BUYRequestOperation
*
operation
=
[
self
getRequestForURL
:
route
start
:
NO
completionHandler
:^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
NSArray
*
shippingRates
=
nil
;
if
(
json
&&
!
error
)
{
shippingRates
=
[
self
.
modelManager
insertShippingRatesWithJSONArray
:
json
[
@"shipping_rates"
]];
...
...
@@ -235,6 +236,13 @@
NSInteger
statusCode
=
[(
NSHTTPURLResponse
*
)
response
statusCode
];
block
(
shippingRates
,
[
self
statusForStatusCode
:
statusCode
error
:
error
],
error
);
}];
operation
.
pollingHandler
=
^
BOOL
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
return
response
.
statusCode
==
BUYStatusProcessing
;
};
[
self
startOperation
:
operation
];
return
operation
;
}
#pragma mark - Payments -
...
...
Mobile Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.m
View file @
6a27c7c2
...
...
@@ -133,12 +133,10 @@
[
weakSelf
locked
:
^
{
weakSelf
.
currentOperation
=
getOperation
;
}];
NSLog
(
@"Getting completed checkout."
);
[
weakSelf
.
client
startOperation
:
getOperation
];
}];
pollOperation
.
pollingHandler
=
^
BOOL
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
NSLog
(
@"Polling checkout..."
);
return
response
.
statusCode
==
BUYStatusProcessing
;
};
...
...
@@ -146,7 +144,6 @@
[
weakSelf
locked
:
^
{
weakSelf
.
currentOperation
=
pollOperation
;
}];
NSLog
(
@"Starting checkout status polling."
);
[
weakSelf
.
client
startOperation
:
pollOperation
];
}];
...
...
@@ -154,7 +151,6 @@
[
self
locked
:
^
{
self
.
currentOperation
=
beginOperation
;
}];
NSLog
(
@"Starting checkout."
);
[
self
.
client
startOperation
:
beginOperation
];
}
...
...
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