Skip to content

Commit 80a094e

Browse files
committed
tests: fixture improvements and fix for objc
- objc native fixtures + fix the generation - missing fixture file results in failing test (for the fixture) (this behaviour is the same as before) but prints a nicer failure message - if the fixture file is missing, snippet test will be set to pending to avoid a double failure - remove done() calls in tests, we are not testing anything asynchronous - improved applciation-form-encoded.json fixture with a new parameter
1 parent 2293bcb commit 80a094e

25 files changed

Lines changed: 214 additions & 96 deletions

src/targets/objc/native.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
var util = require('util');
4+
35
module.exports = function (options) {
46
var opts = util._extend({
57
timeout: '10'
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
curl --request POST \
22
--url "http://mockbin.com/har" \
33
--header "Content-Type: application/x-www-form-urlencoded" \
4-
--form "foo=bar"
4+
--form "foo=bar" \
5+
--form "hello=world"

test/fixtures/output/curl/http1.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
curl --request GET \
2+
--url "http://mockbin.com/request" \
3+
--http1.0
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
http POST http://mockbin.com/har \
22
Content-Type:application/x-www-form-urlencoded \
3-
foo:bar
3+
foo:bar \
4+
hello:world
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
http GET http://mockbin.com/request

test/fixtures/output/node/native/application-form-encoded.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ var req = http.request(options, function (res) {
2323
});
2424
});
2525

26-
var postData = querystring.stringify({"foo":"bar"});
26+
var postData = querystring.stringify({"foo":"bar","hello":"world"});
2727
req.write(postData);
2828
req.end();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var http = require("http");
2+
3+
var options = {
4+
"method": "GET",
5+
"hostname": "mockbin.com",
6+
"port": null,
7+
"path": "/request?",
8+
"headers": {}
9+
};
10+
11+
var req = http.request(options, function (res) {
12+
var chunks = [];
13+
14+
res.on("data", function (chunk) {
15+
chunks.push(chunk);
16+
});
17+
18+
res.on("end", function () {
19+
var body = Buffer.concat(chunks);
20+
});
21+
});
22+
23+
req.end();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#import <Foundation/Foundation.h>
2+
3+
NSURLSession *session = [NSURLSession sharedSession];
4+
5+
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"]
6+
cachePolicy:NSURLRequestUseProtocolCachePolicy
7+
timeoutInterval:10.0];
8+
[request setHTTPMethod:@"POST"];
9+
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
10+
11+
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"foo=bar" dataUsingEncoding:NSUTF8StringEncoding]];
12+
[postData appendData:[@"&hello=world" dataUsingEncoding:NSUTF8StringEncoding]];
13+
[request setHTTPBody:postData];
14+
15+
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
16+
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
17+
18+
}];
19+
20+
[dataTask resume];
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#import <Foundation/Foundation.h>
2+
3+
NSURLSession *session = [NSURLSession sharedSession];
4+
5+
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"]
6+
cachePolicy:NSURLRequestUseProtocolCachePolicy
7+
timeoutInterval:10.0];
8+
[request setHTTPMethod:@"POST"];
9+
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
10+
11+
NSData *postData = [[NSData alloc] initWithData:[@"{\"foo\": \"bar\"}" dataUsingEncoding:NSUTF8StringEncoding]];
12+
[request setHTTPBody:postData];
13+
14+
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
15+
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
16+
17+
}];
18+
19+
[dataTask resume];
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#import <Foundation/Foundation.h>
2+
3+
NSURLSession *session = [NSURLSession sharedSession];
4+
5+
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"]
6+
cachePolicy:NSURLRequestUseProtocolCachePolicy
7+
timeoutInterval:10.0];
8+
[request setHTTPMethod:@"POST"];
9+
[request setValue:@"foo=bar; bar=baz" forHTTPHeaderField:@"Cookie"];
10+
11+
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
12+
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
13+
14+
}];
15+
16+
[dataTask resume];

0 commit comments

Comments
 (0)