Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#11055 from answerrocket/superagent…
Browse files Browse the repository at this point in the history
…-blob

superagent: req.responseType, res.xhr
  • Loading branch information
zhengbli authored Sep 13, 2016
2 parents 0c5c7a2 + f105740 commit 6547d81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion superagent/superagent-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import * as request from 'superagent';
import * as fs from 'fs';
import * as assert from 'assert';

// Examples taken from https://github.com/visionmedia/superagent/blob/gh-pages/docs/index.md
// and https://github.com/visionmedia/superagent/blob/master/Readme.md
Expand Down Expand Up @@ -302,4 +303,14 @@ request
request
.get('/search')
.then((response) => {})
.catch((error) => {});
.catch((error) => {});

// Requesting binary data.
// adapted from: https://github.com/visionmedia/superagent/blob/v2.0.0/test/client/request.js#L110
request
.get('/blob')
.responseType('blob')
.end(function (err, res) {
assert(res.xhr instanceof XMLHttpRequest)
assert(res.xhr.response instanceof Blob);
});
2 changes: 2 additions & 0 deletions superagent/superagent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ declare module "superagent" {
notAcceptable: boolean;
notFound: boolean;
forbidden: boolean;
xhr: XMLHttpRequest;
get(header: string): string;
}

Expand All @@ -96,6 +97,7 @@ declare module "superagent" {
pipe(stream: NodeJS.WritableStream, options?: Object): stream.Writable;
query(val: Object): this;
redirects(n: number): this;
responseType(type: string): this;
send(data: string): this;
send(data: Object): this;
send(): this;
Expand Down

0 comments on commit 6547d81

Please sign in to comment.