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
8fcc265d
Commit
8fcc265d
authored
May 16, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for invalid request case.
parent
36eb71af
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
BUYRequestOperationTests.m
...e Buy SDK/Mobile Buy SDK Tests/BUYRequestOperationTests.m
+33
-0
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYRequestOperationTests.m
View file @
8fcc265d
...
...
@@ -92,6 +92,39 @@
[
self
waitForExpectationsWithTimeout
:
3
.
0
handler
:
nil
];
}
-
(
void
)
testFailedRequest
{
NSDictionary
*
errorPayload
=
@{
@"error"
:
@{
@"reason"
:
@"Invalid length of name"
,
@"field"
:
@"username"
,
},
};
NSData
*
payloadData
=
[
NSJSONSerialization
dataWithJSONObject
:
errorPayload
options
:
0
error
:
nil
];
OHHTTPStubsResponse
*
response
=
[
OHHTTPStubsResponse
responseWithData
:
payloadData
statusCode
:
400
headers
:
nil
];
[
OHHTTPStubs
stubRequestsPassingTest
:
^
BOOL
(
NSURLRequest
*
request
)
{
return
YES
;
}
withStubResponse
:
^
OHHTTPStubsResponse
*
(
NSURLRequest
*
request
)
{
return
response
;
}];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"Expect failed operation"
];
BUYRequestOperation
*
operation
=
[
self
operationFulfillingExpectation
:
expectation
responseCompletion
:
^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
XCTAssertNil
(
json
);
XCTAssertNotNil
(
response
);
XCTAssertNotNil
(
error
);
XCTAssertEqualObjects
(
error
.
userInfo
,
errorPayload
);
XCTAssertEqual
(
response
.
statusCode
,
400
);
}];
[
self
.
queue
addOperation
:
operation
];
[
self
waitForExpectationsWithTimeout
:
3
.
0
handler
:
nil
];
}
#pragma mark - Dependency Tests -
-
(
void
)
testSerialSuccessfulDependencies
...
...
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