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
eed56e94
Commit
eed56e94
authored
May 11, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust test for new architecture.
parent
1fc243ad
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
25 deletions
+24
-25
BUYClientTest.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
+9
-16
BUYIntegrationTest.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYIntegrationTest.m
+15
-9
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
View file @
eed56e94
...
...
@@ -34,6 +34,7 @@
#import "BUYShopifyErrorCodes.h"
#import "BUYAccountCredentials.h"
#import "BUYClient+Customers.h"
#import "BUYApplePayToken.h"
NSString
*
const
BUYFakeCustomerToken
=
@"dsfasdgafdg"
;
...
...
@@ -130,7 +131,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
{
BUYCheckout
*
checkout
=
[[
BUYCheckout
alloc
]
initWithModelManager
:
self
.
client
.
modelManager
JSONDictionary
:@{
@"token"
:
@"abcdef"
,
@"payment_due"
:
@0
}];
NSURLSessionDataTask
*
task
=
[
self
.
client
completeCheckout
:
checkout
completion
:
nil
];
NSURLSessionDataTask
*
task
=
[
self
.
client
completeCheckout
:
checkout
paymentToken
:
nil
completion
:
nil
];
XCTAssertNotNil
(
task
);
}
...
...
@@ -196,23 +197,15 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
-
(
void
)
testCheckoutWithApplePayToken
{
__block
int
callbackCount
=
0
;
[
self
.
client
completeCheckout
:
nil
withApplePayToken
:[
PKPaymentToken
new
]
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
callbackCount
++
;
XCTAssertEqual
(
error
.
code
,
BUYShopifyError_InvalidCheckoutObject
);
}];
id
<
BUYPaymentToken
>
token
=
[[
BUYApplePayToken
alloc
]
initWithPaymentToken
:[
PKPaymentToken
new
]];
XCTAssertThrows
(
[
self
.
client
completeCheckout
:
nil
paymentToken
:
token
completion
:
nil
]
);
BUYCheckout
*
checkout
=
[[
BUYCheckout
alloc
]
initWithModelManager
:
self
.
client
.
modelManager
JSONDictionary
:@{
@"token"
:
@"abcdef"
,
@"payment_due"
:
@0
}];
[
self
.
client
completeCheckout
:
checkout
withApplePayToken
:
nil
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
callbackCount
++
;
XCTAssertEqual
(
error
.
code
,
BUYShopifyError_NoApplePayTokenSpecified
);
}];
XCTAssertEqual
(
callbackCount
,
2
);
[
self
testProductsInCollectionWithSortOrderCollectionDefault
];
XCTAssertNoThrow
(
[
self
.
client
completeCheckout
:
checkout
paymentToken
:
nil
completion
:
nil
]
);
}
-
(
void
)
testQueryItemsConversion
...
...
Mobile Buy SDK/Mobile Buy SDK Tests/BUYIntegrationTest.m
View file @
eed56e94
...
...
@@ -220,7 +220,7 @@
XCTAssertEqualObjects
(
_checkout
.
email
,
@"test@test.com"
);
}
-
(
void
)
addCreditCardToCheckout
-
(
id
<
BUYPaymentToken
>
)
addCreditCardToCheckout
{
[
OHHTTPStubs
stubRequestsPassingTest
:
^
BOOL
(
NSURLRequest
*
_Nonnull
request
)
{
return
[
self
shouldUseMocks
];
...
...
@@ -229,19 +229,23 @@
}];
BUYCreditCard
*
creditCard
=
[
self
creditCard
];
__block
id
<
BUYPaymentToken
>
token
=
nil
;
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
storeCreditCard
:
creditCard
checkout
:
_checkout
completion
:^
(
BUYCheckout
*
returnedCheckout
,
NSString
*
paymentSessionId
,
NSError
*
error
)
{
[
self
.
client
storeCreditCard
:
creditCard
checkout
:
_checkout
completion
:^
(
BUYCheckout
*
returnedCheckout
,
id
<
BUYPaymentToken
>
paymentToken
,
NSError
*
error
)
{
XCTAssertNil
(
error
);
XCTAssertNotNil
(
payment
SessionId
);
XCTAssertNotNil
(
payment
Token
);
XCTAssertNotNil
(
returnedCheckout
);
_checkout
=
returnedCheckout
;
token
=
paymentToken
;
[
expectation
fulfill
];
}];
[
self
waitForExpectationsWithTimeout
:
10
handler
:
^
(
NSError
*
error
)
{
XCTAssertNil
(
error
);
}];
return
token
;
}
-
(
BUYCreditCard
*
)
creditCard
...
...
@@ -256,7 +260,7 @@
return
creditCard
;
}
-
(
void
)
completeCheckout
-
(
void
)
completeCheckout
WithToken
:
(
id
<
BUYPaymentToken
>
)
paymentToken
{
[
OHHTTPStubs
stubRequestsPassingTest
:
^
BOOL
(
NSURLRequest
*
_Nonnull
request
)
{
return
[
self
shouldUseMocks
];
...
...
@@ -265,7 +269,7 @@
}];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
completeCheckout
:
_checkout
completion
:
^
(
BUYCheckout
*
returnedCheckout
,
NSError
*
error
)
{
[
self
.
client
completeCheckout
:
_checkout
paymentToken
:
paymentToken
completion
:^
(
BUYCheckout
*
returnedCheckout
,
NSError
*
error
)
{
XCTAssertNil
(
error
);
XCTAssertNotNil
(
returnedCheckout
);
...
...
@@ -988,8 +992,9 @@
[
self
createCheckout
];
[
self
fetchShippingRates
];
[
self
updateCheckout
];
[
self
addCreditCardToCheckout
];
[
self
completeCheckout
];
id
<
BUYPaymentToken
>
token
=
[
self
addCreditCardToCheckout
];
[
self
completeCheckoutWithToken
:
token
];
[
self
pollUntilCheckoutIsComplete
];
[
self
verifyCompletedCheckout
];
...
...
@@ -1036,8 +1041,9 @@
[
self
updateCheckout
];
//We use a credit card here because we're not generating apple pay tokens in the tests
[
self
addCreditCardToCheckout
];
[
self
completeCheckout
];
id
<
BUYPaymentToken
>
token
=
[
self
addCreditCardToCheckout
];
[
self
completeCheckoutWithToken
:
token
];
[
self
pollUntilCheckoutIsComplete
];
[
self
verifyCompletedCheckout
];
}
...
...
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