Merge pull request #1014 from 0xced/test-response-string-encoding
Add tests for the responseStringEncoding property
This commit is contained in:
commit
c3fab0f315
1 changed files with 36 additions and 0 deletions
|
|
@ -147,6 +147,8 @@
|
|||
expect(numberOfRedirects).will.equal(5);
|
||||
}
|
||||
|
||||
#pragma mark - Pause
|
||||
|
||||
- (void)testThatOperationCanBePaused{
|
||||
[Expecta setAsynchronousTestTimeout:3.0];
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/1" relativeToURL:self.baseURL]];
|
||||
|
|
@ -197,4 +199,38 @@
|
|||
expect(blockResponseObject).willNot.beNil();
|
||||
}
|
||||
|
||||
#pragma mark - Response String Encoding
|
||||
|
||||
- (void) testThatTextStringEncodingIsISOLatin1WhenNoCharsetParameterIsProvided {
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/response-headers?Content-Type=text/plain" relativeToURL:self.baseURL]];
|
||||
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
||||
[operation start];
|
||||
expect([operation isFinished]).will.beTruthy();
|
||||
expect(operation.responseStringEncoding).will.equal(NSISOLatin1StringEncoding);
|
||||
}
|
||||
|
||||
- (void) testThatTextStringEncodingIsShiftJISWhenShiftJISCharsetParameterIsProvided {
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/response-headers?Content-Type=text/plain;%20charset=%22Shift_JIS%22" relativeToURL:self.baseURL]];
|
||||
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
||||
[operation start];
|
||||
expect([operation isFinished]).will.beTruthy();
|
||||
expect(operation.responseStringEncoding).will.equal(NSShiftJISStringEncoding);
|
||||
}
|
||||
|
||||
- (void) testThatTextStringEncodingIsUTF8WhenInvalidCharsetParameterIsProvided {
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/response-headers?Content-Type=text/plain;%20charset=%22invalid%22" relativeToURL:self.baseURL]];
|
||||
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
||||
[operation start];
|
||||
expect([operation isFinished]).will.beTruthy();
|
||||
expect(operation.responseStringEncoding).will.equal(NSUTF8StringEncoding);
|
||||
}
|
||||
|
||||
- (void) testThatTextStringEncodingIsUTF8WhenUTF8CharsetParameterIsProvided {
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/response-headers?Content-Type=text/plain;%20charset=%22UTF-8%22" relativeToURL:self.baseURL]];
|
||||
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
||||
[operation start];
|
||||
expect([operation isFinished]).will.beTruthy();
|
||||
expect(operation.responseStringEncoding).will.equal(NSUTF8StringEncoding);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue