@alterior/http 3.11.1 → 3.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend.d.ts +38 -38
- package/dist/backend.js +38 -38
- package/dist/client.d.ts +2108 -2108
- package/dist/client.js +265 -265
- package/dist/client.js.map +1 -1
- package/dist/headers.d.ts +57 -57
- package/dist/headers.js +187 -187
- package/dist/headers.js.map +1 -1
- package/dist/index.d.ts +18 -18
- package/dist/index.js +42 -42
- package/dist/interceptor.d.ts +63 -63
- package/dist/interceptor.js +43 -43
- package/dist/interceptor.js.map +1 -1
- package/dist/module.d.ts +101 -101
- package/dist/module.js +188 -188
- package/dist/module.js.map +1 -1
- package/dist/params.d.ts +98 -98
- package/dist/params.js +184 -184
- package/dist/params.js.map +1 -1
- package/dist/request.d.ts +130 -130
- package/dist/request.js +260 -260
- package/dist/request.js.map +1 -1
- package/dist/response.d.ts +267 -267
- package/dist/response.js +165 -165
- package/dist/response.js.map +1 -1
- package/dist/server.d.ts +28 -28
- package/dist/server.js +119 -119
- package/dist/server.js.map +1 -1
- package/dist/test/client.test.d.ts +8 -8
- package/dist/test/client.test.js +163 -163
- package/dist/test/client.test.js.map +1 -1
- package/dist/test/headers.test.d.ts +1 -1
- package/dist/test/headers.test.js +126 -126
- package/dist/test/module.test.d.ts +1 -1
- package/dist/test/module.test.js +117 -117
- package/dist/test/module.test.js.map +1 -1
- package/dist/test/params.test.d.ts +1 -1
- package/dist/test/params.test.js +63 -63
- package/dist/test/request.test.d.ts +8 -8
- package/dist/test/request.test.js +159 -159
- package/dist/test/request.test.js.map +1 -1
- package/dist/test/response.test.d.ts +1 -1
- package/dist/test/response.test.js +79 -79
- package/dist/test/response.test.js.map +1 -1
- package/dist/test/test.d.ts +1 -1
- package/dist/test/test.js +16 -16
- package/dist/test/xhr.mock.d.ts +48 -48
- package/dist/test/xhr.mock.js +94 -94
- package/dist/test/xhr.mock.js.map +1 -1
- package/dist/test/xhr.test.d.ts +1 -1
- package/dist/test/xhr.test.js +344 -344
- package/dist/test/xhr.test.js.map +1 -1
- package/dist/test/xsrf.test.d.ts +1 -1
- package/dist/test/xsrf.test.js +63 -63
- package/dist/test/xsrf.test.js.map +1 -1
- package/dist/testing/api.d.ts +102 -102
- package/dist/testing/api.js +19 -19
- package/dist/testing/backend.d.ts +63 -63
- package/dist/testing/backend.js +141 -141
- package/dist/testing/backend.js.map +1 -1
- package/dist/testing/index.d.ts +10 -10
- package/dist/testing/index.js +16 -16
- package/dist/testing/module.d.ts +16 -16
- package/dist/testing/module.js +38 -38
- package/dist/testing/module.js.map +1 -1
- package/dist/testing/request.d.ts +56 -56
- package/dist/testing/request.js +177 -177
- package/dist/testing/request.js.map +1 -1
- package/dist/testing/request.test.d.ts +8 -8
- package/dist/testing/request.test.js +24 -24
- package/dist/xhr.d.ts +42 -42
- package/dist/xhr.js +298 -298
- package/dist/xhr.js.map +1 -1
- package/dist/xsrf.d.ts +37 -37
- package/dist/xsrf.js +55 -55
- package/dist/xsrf.js.map +1 -1
- package/dist.esm/backend.d.ts +38 -38
- package/dist.esm/backend.js +33 -33
- package/dist.esm/client.d.ts +2108 -2108
- package/dist.esm/client.js +262 -262
- package/dist.esm/client.js.map +1 -1
- package/dist.esm/headers.d.ts +57 -57
- package/dist.esm/headers.js +183 -183
- package/dist.esm/headers.js.map +1 -1
- package/dist.esm/index.d.ts +18 -18
- package/dist.esm/index.js +18 -18
- package/dist.esm/interceptor.d.ts +63 -63
- package/dist.esm/interceptor.js +39 -39
- package/dist.esm/interceptor.js.map +1 -1
- package/dist.esm/module.d.ts +101 -101
- package/dist.esm/module.js +183 -183
- package/dist.esm/module.js.map +1 -1
- package/dist.esm/params.d.ts +98 -98
- package/dist.esm/params.js +179 -179
- package/dist.esm/params.js.map +1 -1
- package/dist.esm/request.d.ts +130 -130
- package/dist.esm/request.js +256 -256
- package/dist.esm/request.js.map +1 -1
- package/dist.esm/response.d.ts +267 -267
- package/dist.esm/response.js +158 -158
- package/dist.esm/response.js.map +1 -1
- package/dist.esm/server.d.ts +28 -28
- package/dist.esm/server.js +113 -113
- package/dist.esm/server.js.map +1 -1
- package/dist.esm/test/client.test.d.ts +8 -8
- package/dist.esm/test/client.test.js +161 -161
- package/dist.esm/test/client.test.js.map +1 -1
- package/dist.esm/test/headers.test.d.ts +1 -1
- package/dist.esm/test/headers.test.js +124 -124
- package/dist.esm/test/module.test.d.ts +1 -1
- package/dist.esm/test/module.test.js +115 -115
- package/dist.esm/test/module.test.js.map +1 -1
- package/dist.esm/test/params.test.d.ts +1 -1
- package/dist.esm/test/params.test.js +61 -61
- package/dist.esm/test/request.test.d.ts +8 -8
- package/dist.esm/test/request.test.js +157 -157
- package/dist.esm/test/request.test.js.map +1 -1
- package/dist.esm/test/response.test.d.ts +1 -1
- package/dist.esm/test/response.test.js +77 -77
- package/dist.esm/test/response.test.js.map +1 -1
- package/dist.esm/test/test.d.ts +1 -1
- package/dist.esm/test/test.js +14 -14
- package/dist.esm/test/xhr.mock.d.ts +48 -48
- package/dist.esm/test/xhr.mock.js +88 -88
- package/dist.esm/test/xhr.mock.js.map +1 -1
- package/dist.esm/test/xhr.test.d.ts +1 -1
- package/dist.esm/test/xhr.test.js +342 -342
- package/dist.esm/test/xhr.test.js.map +1 -1
- package/dist.esm/test/xsrf.test.d.ts +1 -1
- package/dist.esm/test/xsrf.test.js +61 -61
- package/dist.esm/test/xsrf.test.js.map +1 -1
- package/dist.esm/testing/api.d.ts +102 -102
- package/dist.esm/testing/api.js +15 -15
- package/dist.esm/testing/backend.d.ts +63 -63
- package/dist.esm/testing/backend.js +138 -138
- package/dist.esm/testing/backend.js.map +1 -1
- package/dist.esm/testing/index.d.ts +10 -10
- package/dist.esm/testing/index.js +10 -10
- package/dist.esm/testing/module.d.ts +16 -16
- package/dist.esm/testing/module.js +35 -35
- package/dist.esm/testing/module.js.map +1 -1
- package/dist.esm/testing/request.d.ts +56 -56
- package/dist.esm/testing/request.js +173 -173
- package/dist.esm/testing/request.js.map +1 -1
- package/dist.esm/testing/request.test.d.ts +8 -8
- package/dist.esm/testing/request.test.js +22 -22
- package/dist.esm/xhr.d.ts +42 -42
- package/dist.esm/xhr.js +294 -294
- package/dist.esm/xhr.js.map +1 -1
- package/dist.esm/xsrf.d.ts +37 -37
- package/dist.esm/xsrf.js +51 -51
- package/dist.esm/xsrf.js.map +1 -1
- package/package.json +11 -11
- package/tsconfig.esm.tsbuildinfo +1 -0
- package/tsconfig.json +0 -2
- package/tsconfig.tsbuildinfo +1 -8046
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { describe, it } from 'razmin';
|
|
9
|
-
import { expect } from 'chai';
|
|
10
|
-
import { HttpHeaders } from '../headers';
|
|
11
|
-
import { HttpParams } from '../params';
|
|
12
|
-
import { HttpRequest } from '../request';
|
|
13
|
-
const TEST_URL = 'http://angular.io';
|
|
14
|
-
const TEST_STRING = `I'm a body!`;
|
|
15
|
-
{
|
|
16
|
-
describe('HttpRequest', () => {
|
|
17
|
-
describe('constructor', () => {
|
|
18
|
-
it('initializes url', () => {
|
|
19
|
-
const req = new HttpRequest('', TEST_URL, null);
|
|
20
|
-
expect(req.url).to.equal(TEST_URL);
|
|
21
|
-
});
|
|
22
|
-
it('doesn\'t require a body for body-less methods', () => {
|
|
23
|
-
let req = new HttpRequest('GET', TEST_URL);
|
|
24
|
-
expect(req.method).to.equal('GET');
|
|
25
|
-
expect(req.body).to.be.null;
|
|
26
|
-
req = new HttpRequest('HEAD', TEST_URL);
|
|
27
|
-
expect(req.method).to.equal('HEAD');
|
|
28
|
-
expect(req.body).to.be.null;
|
|
29
|
-
req = new HttpRequest('JSONP', TEST_URL);
|
|
30
|
-
expect(req.method).to.equal('JSONP');
|
|
31
|
-
expect(req.body).to.be.null;
|
|
32
|
-
req = new HttpRequest('OPTIONS', TEST_URL);
|
|
33
|
-
expect(req.method).to.equal('OPTIONS');
|
|
34
|
-
expect(req.body).to.be.null;
|
|
35
|
-
});
|
|
36
|
-
it('accepts a string request method', () => {
|
|
37
|
-
const req = new HttpRequest('TEST', TEST_URL, null);
|
|
38
|
-
expect(req.method).to.equal('TEST');
|
|
39
|
-
});
|
|
40
|
-
it('accepts a string body', () => {
|
|
41
|
-
const req = new HttpRequest('POST', TEST_URL, TEST_STRING);
|
|
42
|
-
expect(req.body).to.equal(TEST_STRING);
|
|
43
|
-
});
|
|
44
|
-
it('accepts an object body', () => {
|
|
45
|
-
const req = new HttpRequest('POST', TEST_URL, { data: TEST_STRING });
|
|
46
|
-
expect(req.body).to.eql({ data: TEST_STRING });
|
|
47
|
-
});
|
|
48
|
-
it('creates default headers if not passed', () => {
|
|
49
|
-
const req = new HttpRequest('GET', TEST_URL);
|
|
50
|
-
expect(req.headers instanceof HttpHeaders).to.be.ok;
|
|
51
|
-
});
|
|
52
|
-
it('uses the provided headers if passed', () => {
|
|
53
|
-
const headers = new HttpHeaders();
|
|
54
|
-
const req = new HttpRequest('GET', TEST_URL, { headers });
|
|
55
|
-
expect(req.headers).to.equal(headers);
|
|
56
|
-
});
|
|
57
|
-
it('defaults to Json', () => {
|
|
58
|
-
const req = new HttpRequest('GET', TEST_URL);
|
|
59
|
-
expect(req.responseType).to.equal('json');
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
describe('clone() copies the request', () => {
|
|
63
|
-
const headers = new HttpHeaders({
|
|
64
|
-
'Test': 'Test header',
|
|
65
|
-
});
|
|
66
|
-
const req = new HttpRequest('POST', TEST_URL, 'test body', {
|
|
67
|
-
headers,
|
|
68
|
-
reportProgress: true,
|
|
69
|
-
responseType: 'text',
|
|
70
|
-
withCredentials: true,
|
|
71
|
-
});
|
|
72
|
-
it('in the base case', () => {
|
|
73
|
-
const clone = req.clone();
|
|
74
|
-
expect(clone.method).to.equal('POST');
|
|
75
|
-
expect(clone.responseType).to.equal('text');
|
|
76
|
-
expect(clone.url).to.equal(TEST_URL);
|
|
77
|
-
// Headers should be the same, as the headers are sealed.
|
|
78
|
-
expect(clone.headers).to.equal(headers);
|
|
79
|
-
expect(clone.headers.get('Test')).to.equal('Test header');
|
|
80
|
-
});
|
|
81
|
-
it('and updates the url', () => { expect(req.clone({ url: '/changed' }).url).to.equal('/changed'); });
|
|
82
|
-
it('and updates the method', () => { expect(req.clone({ method: 'PUT' }).method).to.equal('PUT'); });
|
|
83
|
-
it('and updates the body', () => { expect(req.clone({ body: 'changed body' }).body).to.equal('changed body'); });
|
|
84
|
-
});
|
|
85
|
-
describe('content type detection', () => {
|
|
86
|
-
const baseReq = new HttpRequest('POST', '/test', null);
|
|
87
|
-
it('handles a null body', () => { expect(baseReq.detectContentTypeHeader()).to.be.null; });
|
|
88
|
-
it('doesn\'t associate a content type with ArrayBuffers', () => {
|
|
89
|
-
const req = baseReq.clone({ body: new ArrayBuffer(4) });
|
|
90
|
-
expect(req.detectContentTypeHeader()).to.be.null;
|
|
91
|
-
});
|
|
92
|
-
it('handles strings as text', () => {
|
|
93
|
-
const req = baseReq.clone({ body: 'hello world' });
|
|
94
|
-
expect(req.detectContentTypeHeader()).to.equal('text/plain');
|
|
95
|
-
});
|
|
96
|
-
it('handles arrays as json', () => {
|
|
97
|
-
const req = baseReq.clone({ body: ['a', 'b'] });
|
|
98
|
-
expect(req.detectContentTypeHeader()).to.equal('application/json');
|
|
99
|
-
});
|
|
100
|
-
it('handles numbers as json', () => {
|
|
101
|
-
const req = baseReq.clone({ body: 314159 });
|
|
102
|
-
expect(req.detectContentTypeHeader()).to.equal('application/json');
|
|
103
|
-
});
|
|
104
|
-
it('handles objects as json', () => {
|
|
105
|
-
const req = baseReq.clone({ body: { data: 'test data' } });
|
|
106
|
-
expect(req.detectContentTypeHeader()).to.equal('application/json');
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
describe('body serialization', () => {
|
|
110
|
-
const baseReq = new HttpRequest('POST', '/test', null);
|
|
111
|
-
it('handles a null body', () => { expect(baseReq.serializeBody()).to.be.null; });
|
|
112
|
-
it('passes ArrayBuffers through', () => {
|
|
113
|
-
const body = new ArrayBuffer(4);
|
|
114
|
-
expect(baseReq.clone({ body }).serializeBody()).to.equal(body);
|
|
115
|
-
});
|
|
116
|
-
it('passes strings through', () => {
|
|
117
|
-
const body = 'hello world';
|
|
118
|
-
expect(baseReq.clone({ body }).serializeBody()).to.equal(body);
|
|
119
|
-
});
|
|
120
|
-
it('serializes arrays as json', () => {
|
|
121
|
-
expect(baseReq.clone({ body: ['a', 'b'] }).serializeBody()).to.equal('["a","b"]');
|
|
122
|
-
});
|
|
123
|
-
it('handles numbers as json', () => { expect(baseReq.clone({ body: 314159 }).serializeBody()).to.equal('314159'); });
|
|
124
|
-
it('handles objects as json', () => {
|
|
125
|
-
const req = baseReq.clone({ body: { data: 'test data' } });
|
|
126
|
-
expect(req.serializeBody()).to.equal('{"data":"test data"}');
|
|
127
|
-
});
|
|
128
|
-
it('serializes parameters as urlencoded', () => {
|
|
129
|
-
const params = new HttpParams().append('first', 'value').append('second', 'other');
|
|
130
|
-
const withParams = baseReq.clone({ body: params });
|
|
131
|
-
expect(withParams.serializeBody()).to.equal('first=value&second=other');
|
|
132
|
-
expect(withParams.detectContentTypeHeader())
|
|
133
|
-
.to.equal('application/x-www-form-urlencoded;charset=UTF-8');
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
describe('parameter handling', () => {
|
|
137
|
-
const baseReq = new HttpRequest('GET', '/test', null);
|
|
138
|
-
const params = new HttpParams({ fromString: 'test=true' });
|
|
139
|
-
it('appends parameters to a base URL', () => {
|
|
140
|
-
const req = baseReq.clone({ params });
|
|
141
|
-
expect(req.urlWithParams).to.equal('/test?test=true');
|
|
142
|
-
});
|
|
143
|
-
it('appends parameters to a URL with an empty query string', () => {
|
|
144
|
-
const req = baseReq.clone({ params, url: '/test?' });
|
|
145
|
-
expect(req.urlWithParams).to.equal('/test?test=true');
|
|
146
|
-
});
|
|
147
|
-
it('appends parameters to a URL with a query string', () => {
|
|
148
|
-
const req = baseReq.clone({ params, url: '/test?other=false' });
|
|
149
|
-
expect(req.urlWithParams).to.equal('/test?other=false&test=true');
|
|
150
|
-
});
|
|
151
|
-
it('sets parameters via setParams', () => {
|
|
152
|
-
const req = baseReq.clone({ setParams: { 'test': 'false' } });
|
|
153
|
-
expect(req.urlWithParams).to.equal('/test?test=false');
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { describe, it } from 'razmin';
|
|
9
|
+
import { expect } from 'chai';
|
|
10
|
+
import { HttpHeaders } from '../headers';
|
|
11
|
+
import { HttpParams } from '../params';
|
|
12
|
+
import { HttpRequest } from '../request';
|
|
13
|
+
const TEST_URL = 'http://angular.io';
|
|
14
|
+
const TEST_STRING = `I'm a body!`;
|
|
15
|
+
{
|
|
16
|
+
describe('HttpRequest', () => {
|
|
17
|
+
describe('constructor', () => {
|
|
18
|
+
it('initializes url', () => {
|
|
19
|
+
const req = new HttpRequest('', TEST_URL, null);
|
|
20
|
+
expect(req.url).to.equal(TEST_URL);
|
|
21
|
+
});
|
|
22
|
+
it('doesn\'t require a body for body-less methods', () => {
|
|
23
|
+
let req = new HttpRequest('GET', TEST_URL);
|
|
24
|
+
expect(req.method).to.equal('GET');
|
|
25
|
+
expect(req.body).to.be.null;
|
|
26
|
+
req = new HttpRequest('HEAD', TEST_URL);
|
|
27
|
+
expect(req.method).to.equal('HEAD');
|
|
28
|
+
expect(req.body).to.be.null;
|
|
29
|
+
req = new HttpRequest('JSONP', TEST_URL);
|
|
30
|
+
expect(req.method).to.equal('JSONP');
|
|
31
|
+
expect(req.body).to.be.null;
|
|
32
|
+
req = new HttpRequest('OPTIONS', TEST_URL);
|
|
33
|
+
expect(req.method).to.equal('OPTIONS');
|
|
34
|
+
expect(req.body).to.be.null;
|
|
35
|
+
});
|
|
36
|
+
it('accepts a string request method', () => {
|
|
37
|
+
const req = new HttpRequest('TEST', TEST_URL, null);
|
|
38
|
+
expect(req.method).to.equal('TEST');
|
|
39
|
+
});
|
|
40
|
+
it('accepts a string body', () => {
|
|
41
|
+
const req = new HttpRequest('POST', TEST_URL, TEST_STRING);
|
|
42
|
+
expect(req.body).to.equal(TEST_STRING);
|
|
43
|
+
});
|
|
44
|
+
it('accepts an object body', () => {
|
|
45
|
+
const req = new HttpRequest('POST', TEST_URL, { data: TEST_STRING });
|
|
46
|
+
expect(req.body).to.eql({ data: TEST_STRING });
|
|
47
|
+
});
|
|
48
|
+
it('creates default headers if not passed', () => {
|
|
49
|
+
const req = new HttpRequest('GET', TEST_URL);
|
|
50
|
+
expect(req.headers instanceof HttpHeaders).to.be.ok;
|
|
51
|
+
});
|
|
52
|
+
it('uses the provided headers if passed', () => {
|
|
53
|
+
const headers = new HttpHeaders();
|
|
54
|
+
const req = new HttpRequest('GET', TEST_URL, { headers });
|
|
55
|
+
expect(req.headers).to.equal(headers);
|
|
56
|
+
});
|
|
57
|
+
it('defaults to Json', () => {
|
|
58
|
+
const req = new HttpRequest('GET', TEST_URL);
|
|
59
|
+
expect(req.responseType).to.equal('json');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('clone() copies the request', () => {
|
|
63
|
+
const headers = new HttpHeaders({
|
|
64
|
+
'Test': 'Test header',
|
|
65
|
+
});
|
|
66
|
+
const req = new HttpRequest('POST', TEST_URL, 'test body', {
|
|
67
|
+
headers,
|
|
68
|
+
reportProgress: true,
|
|
69
|
+
responseType: 'text',
|
|
70
|
+
withCredentials: true,
|
|
71
|
+
});
|
|
72
|
+
it('in the base case', () => {
|
|
73
|
+
const clone = req.clone();
|
|
74
|
+
expect(clone.method).to.equal('POST');
|
|
75
|
+
expect(clone.responseType).to.equal('text');
|
|
76
|
+
expect(clone.url).to.equal(TEST_URL);
|
|
77
|
+
// Headers should be the same, as the headers are sealed.
|
|
78
|
+
expect(clone.headers).to.equal(headers);
|
|
79
|
+
expect(clone.headers.get('Test')).to.equal('Test header');
|
|
80
|
+
});
|
|
81
|
+
it('and updates the url', () => { expect(req.clone({ url: '/changed' }).url).to.equal('/changed'); });
|
|
82
|
+
it('and updates the method', () => { expect(req.clone({ method: 'PUT' }).method).to.equal('PUT'); });
|
|
83
|
+
it('and updates the body', () => { expect(req.clone({ body: 'changed body' }).body).to.equal('changed body'); });
|
|
84
|
+
});
|
|
85
|
+
describe('content type detection', () => {
|
|
86
|
+
const baseReq = new HttpRequest('POST', '/test', null);
|
|
87
|
+
it('handles a null body', () => { expect(baseReq.detectContentTypeHeader()).to.be.null; });
|
|
88
|
+
it('doesn\'t associate a content type with ArrayBuffers', () => {
|
|
89
|
+
const req = baseReq.clone({ body: new ArrayBuffer(4) });
|
|
90
|
+
expect(req.detectContentTypeHeader()).to.be.null;
|
|
91
|
+
});
|
|
92
|
+
it('handles strings as text', () => {
|
|
93
|
+
const req = baseReq.clone({ body: 'hello world' });
|
|
94
|
+
expect(req.detectContentTypeHeader()).to.equal('text/plain');
|
|
95
|
+
});
|
|
96
|
+
it('handles arrays as json', () => {
|
|
97
|
+
const req = baseReq.clone({ body: ['a', 'b'] });
|
|
98
|
+
expect(req.detectContentTypeHeader()).to.equal('application/json');
|
|
99
|
+
});
|
|
100
|
+
it('handles numbers as json', () => {
|
|
101
|
+
const req = baseReq.clone({ body: 314159 });
|
|
102
|
+
expect(req.detectContentTypeHeader()).to.equal('application/json');
|
|
103
|
+
});
|
|
104
|
+
it('handles objects as json', () => {
|
|
105
|
+
const req = baseReq.clone({ body: { data: 'test data' } });
|
|
106
|
+
expect(req.detectContentTypeHeader()).to.equal('application/json');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe('body serialization', () => {
|
|
110
|
+
const baseReq = new HttpRequest('POST', '/test', null);
|
|
111
|
+
it('handles a null body', () => { expect(baseReq.serializeBody()).to.be.null; });
|
|
112
|
+
it('passes ArrayBuffers through', () => {
|
|
113
|
+
const body = new ArrayBuffer(4);
|
|
114
|
+
expect(baseReq.clone({ body }).serializeBody()).to.equal(body);
|
|
115
|
+
});
|
|
116
|
+
it('passes strings through', () => {
|
|
117
|
+
const body = 'hello world';
|
|
118
|
+
expect(baseReq.clone({ body }).serializeBody()).to.equal(body);
|
|
119
|
+
});
|
|
120
|
+
it('serializes arrays as json', () => {
|
|
121
|
+
expect(baseReq.clone({ body: ['a', 'b'] }).serializeBody()).to.equal('["a","b"]');
|
|
122
|
+
});
|
|
123
|
+
it('handles numbers as json', () => { expect(baseReq.clone({ body: 314159 }).serializeBody()).to.equal('314159'); });
|
|
124
|
+
it('handles objects as json', () => {
|
|
125
|
+
const req = baseReq.clone({ body: { data: 'test data' } });
|
|
126
|
+
expect(req.serializeBody()).to.equal('{"data":"test data"}');
|
|
127
|
+
});
|
|
128
|
+
it('serializes parameters as urlencoded', () => {
|
|
129
|
+
const params = new HttpParams().append('first', 'value').append('second', 'other');
|
|
130
|
+
const withParams = baseReq.clone({ body: params });
|
|
131
|
+
expect(withParams.serializeBody()).to.equal('first=value&second=other');
|
|
132
|
+
expect(withParams.detectContentTypeHeader())
|
|
133
|
+
.to.equal('application/x-www-form-urlencoded;charset=UTF-8');
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
describe('parameter handling', () => {
|
|
137
|
+
const baseReq = new HttpRequest('GET', '/test', null);
|
|
138
|
+
const params = new HttpParams({ fromString: 'test=true' });
|
|
139
|
+
it('appends parameters to a base URL', () => {
|
|
140
|
+
const req = baseReq.clone({ params });
|
|
141
|
+
expect(req.urlWithParams).to.equal('/test?test=true');
|
|
142
|
+
});
|
|
143
|
+
it('appends parameters to a URL with an empty query string', () => {
|
|
144
|
+
const req = baseReq.clone({ params, url: '/test?' });
|
|
145
|
+
expect(req.urlWithParams).to.equal('/test?test=true');
|
|
146
|
+
});
|
|
147
|
+
it('appends parameters to a URL with a query string', () => {
|
|
148
|
+
const req = baseReq.clone({ params, url: '/test?other=false' });
|
|
149
|
+
expect(req.urlWithParams).to.equal('/test?other=false&test=true');
|
|
150
|
+
});
|
|
151
|
+
it('sets parameters via setParams', () => {
|
|
152
|
+
const req = baseReq.clone({ setParams: { 'test': 'false' } });
|
|
153
|
+
expect(req.urlWithParams).to.equal('/test?test=false');
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
158
|
//# sourceMappingURL=request.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.test.js","sourceRoot":"","sources":["../../src/test/request.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AACrC,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAEvC,MAAM,QAAQ,GAAG,mBAAmB,CAAC;AACrC,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC;
|
|
1
|
+
{"version":3,"file":"request.test.js","sourceRoot":"","sources":["../../src/test/request.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,UAAU,EAA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@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=response.test.d.ts.map
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { describe, it } from 'razmin';
|
|
9
|
-
import { expect } from 'chai';
|
|
10
|
-
import { HttpHeaders } from '../headers';
|
|
11
|
-
import { HttpResponse } from '../response';
|
|
12
|
-
{
|
|
13
|
-
describe('HttpResponse', () => {
|
|
14
|
-
describe('constructor()', () => {
|
|
15
|
-
it('fully constructs responses', () => {
|
|
16
|
-
const resp = new HttpResponse({
|
|
17
|
-
body: 'test body',
|
|
18
|
-
headers: new HttpHeaders({
|
|
19
|
-
'Test': 'Test header',
|
|
20
|
-
}),
|
|
21
|
-
status: 201,
|
|
22
|
-
statusText: 'Created',
|
|
23
|
-
url: '/test',
|
|
24
|
-
});
|
|
25
|
-
expect(resp.body).to.equal('test body');
|
|
26
|
-
expect(resp.headers instanceof HttpHeaders).to.be.ok;
|
|
27
|
-
expect(resp.headers.get('Test')).to.equal('Test header');
|
|
28
|
-
expect(resp.status).to.equal(201);
|
|
29
|
-
expect(resp.statusText).to.equal('Created');
|
|
30
|
-
expect(resp.url).to.equal('/test');
|
|
31
|
-
});
|
|
32
|
-
it('uses defaults if no args passed', () => {
|
|
33
|
-
const resp = new HttpResponse({});
|
|
34
|
-
expect(resp.headers).not.to.be.null;
|
|
35
|
-
expect(resp.status).to.equal(200);
|
|
36
|
-
expect(resp.statusText).to.equal('OK');
|
|
37
|
-
expect(resp.body).to.be.null;
|
|
38
|
-
expect(resp.ok).to.be.ok;
|
|
39
|
-
expect(resp.url).to.be.null;
|
|
40
|
-
});
|
|
41
|
-
it('accepts a falsy body', () => {
|
|
42
|
-
expect(new HttpResponse({ body: false }).body).to.equal(false);
|
|
43
|
-
expect(new HttpResponse({ body: 0 }).body).to.equal(0);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
it('.ok is determined by status', () => {
|
|
47
|
-
const good = new HttpResponse({ status: 200 });
|
|
48
|
-
const alsoGood = new HttpResponse({ status: 299 });
|
|
49
|
-
const badHigh = new HttpResponse({ status: 300 });
|
|
50
|
-
const badLow = new HttpResponse({ status: 199 });
|
|
51
|
-
expect(good.ok).to.equal(true);
|
|
52
|
-
expect(alsoGood.ok).to.equal(true);
|
|
53
|
-
expect(badHigh.ok).to.equal(false);
|
|
54
|
-
expect(badLow.ok).to.equal(false);
|
|
55
|
-
});
|
|
56
|
-
describe('.clone()', () => {
|
|
57
|
-
it('copies the original when given no arguments', () => {
|
|
58
|
-
const clone = new HttpResponse({ body: 'test', status: 201, statusText: 'created', url: '/test' })
|
|
59
|
-
.clone();
|
|
60
|
-
expect(clone.body).to.equal('test');
|
|
61
|
-
expect(clone.status).to.equal(201);
|
|
62
|
-
expect(clone.statusText).to.equal('created');
|
|
63
|
-
expect(clone.url).to.equal('/test');
|
|
64
|
-
expect(clone.headers).not.to.be.null;
|
|
65
|
-
});
|
|
66
|
-
it('overrides the original', () => {
|
|
67
|
-
const orig = new HttpResponse({ body: 'test', status: 201, statusText: 'created', url: '/test' });
|
|
68
|
-
const clone = orig.clone({ body: { data: 'test' }, status: 200, statusText: 'Okay', url: '/bar' });
|
|
69
|
-
expect(clone.body).to.eql({ data: 'test' });
|
|
70
|
-
expect(clone.status).to.equal(200);
|
|
71
|
-
expect(clone.statusText).to.equal('Okay');
|
|
72
|
-
expect(clone.url).to.equal('/bar');
|
|
73
|
-
expect(clone.headers).to.equal(orig.headers);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { describe, it } from 'razmin';
|
|
9
|
+
import { expect } from 'chai';
|
|
10
|
+
import { HttpHeaders } from '../headers';
|
|
11
|
+
import { HttpResponse } from '../response';
|
|
12
|
+
{
|
|
13
|
+
describe('HttpResponse', () => {
|
|
14
|
+
describe('constructor()', () => {
|
|
15
|
+
it('fully constructs responses', () => {
|
|
16
|
+
const resp = new HttpResponse({
|
|
17
|
+
body: 'test body',
|
|
18
|
+
headers: new HttpHeaders({
|
|
19
|
+
'Test': 'Test header',
|
|
20
|
+
}),
|
|
21
|
+
status: 201,
|
|
22
|
+
statusText: 'Created',
|
|
23
|
+
url: '/test',
|
|
24
|
+
});
|
|
25
|
+
expect(resp.body).to.equal('test body');
|
|
26
|
+
expect(resp.headers instanceof HttpHeaders).to.be.ok;
|
|
27
|
+
expect(resp.headers.get('Test')).to.equal('Test header');
|
|
28
|
+
expect(resp.status).to.equal(201);
|
|
29
|
+
expect(resp.statusText).to.equal('Created');
|
|
30
|
+
expect(resp.url).to.equal('/test');
|
|
31
|
+
});
|
|
32
|
+
it('uses defaults if no args passed', () => {
|
|
33
|
+
const resp = new HttpResponse({});
|
|
34
|
+
expect(resp.headers).not.to.be.null;
|
|
35
|
+
expect(resp.status).to.equal(200);
|
|
36
|
+
expect(resp.statusText).to.equal('OK');
|
|
37
|
+
expect(resp.body).to.be.null;
|
|
38
|
+
expect(resp.ok).to.be.ok;
|
|
39
|
+
expect(resp.url).to.be.null;
|
|
40
|
+
});
|
|
41
|
+
it('accepts a falsy body', () => {
|
|
42
|
+
expect(new HttpResponse({ body: false }).body).to.equal(false);
|
|
43
|
+
expect(new HttpResponse({ body: 0 }).body).to.equal(0);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
it('.ok is determined by status', () => {
|
|
47
|
+
const good = new HttpResponse({ status: 200 });
|
|
48
|
+
const alsoGood = new HttpResponse({ status: 299 });
|
|
49
|
+
const badHigh = new HttpResponse({ status: 300 });
|
|
50
|
+
const badLow = new HttpResponse({ status: 199 });
|
|
51
|
+
expect(good.ok).to.equal(true);
|
|
52
|
+
expect(alsoGood.ok).to.equal(true);
|
|
53
|
+
expect(badHigh.ok).to.equal(false);
|
|
54
|
+
expect(badLow.ok).to.equal(false);
|
|
55
|
+
});
|
|
56
|
+
describe('.clone()', () => {
|
|
57
|
+
it('copies the original when given no arguments', () => {
|
|
58
|
+
const clone = new HttpResponse({ body: 'test', status: 201, statusText: 'created', url: '/test' })
|
|
59
|
+
.clone();
|
|
60
|
+
expect(clone.body).to.equal('test');
|
|
61
|
+
expect(clone.status).to.equal(201);
|
|
62
|
+
expect(clone.statusText).to.equal('created');
|
|
63
|
+
expect(clone.url).to.equal('/test');
|
|
64
|
+
expect(clone.headers).not.to.be.null;
|
|
65
|
+
});
|
|
66
|
+
it('overrides the original', () => {
|
|
67
|
+
const orig = new HttpResponse({ body: 'test', status: 201, statusText: 'created', url: '/test' });
|
|
68
|
+
const clone = orig.clone({ body: { data: 'test' }, status: 200, statusText: 'Okay', url: '/bar' });
|
|
69
|
+
expect(clone.body).to.eql({ data: 'test' });
|
|
70
|
+
expect(clone.status).to.equal(200);
|
|
71
|
+
expect(clone.statusText).to.equal('Okay');
|
|
72
|
+
expect(clone.url).to.equal('/bar');
|
|
73
|
+
expect(clone.headers).to.equal(orig.headers);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
78
|
//# sourceMappingURL=response.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.test.js","sourceRoot":"","sources":["../../src/test/response.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC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
|
package/dist.esm/test/test.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "reflect-metadata";
|
|
1
|
+
import "reflect-metadata";
|
|
2
2
|
//# sourceMappingURL=test.d.ts.map
|
package/dist.esm/test/test.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import "reflect-metadata";
|
|
2
|
-
import { suite } from "razmin";
|
|
3
|
-
suite()
|
|
4
|
-
.include([
|
|
5
|
-
'**/client.test.js',
|
|
6
|
-
'**/headers.test.js',
|
|
7
|
-
'**/module.test.js',
|
|
8
|
-
'**/params.test.js',
|
|
9
|
-
'**/request.test.js',
|
|
10
|
-
'**/response.test.js',
|
|
11
|
-
'**/xhr.test.js',
|
|
12
|
-
'**/xsrf.test.js',
|
|
13
|
-
])
|
|
14
|
-
.run();
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { suite } from "razmin";
|
|
3
|
+
suite()
|
|
4
|
+
.include([
|
|
5
|
+
'**/client.test.js',
|
|
6
|
+
'**/headers.test.js',
|
|
7
|
+
'**/module.test.js',
|
|
8
|
+
'**/params.test.js',
|
|
9
|
+
'**/request.test.js',
|
|
10
|
+
'**/response.test.js',
|
|
11
|
+
'**/xhr.test.js',
|
|
12
|
+
'**/xsrf.test.js',
|
|
13
|
+
])
|
|
14
|
+
.run();
|
|
15
15
|
//# sourceMappingURL=test.js.map
|