@ -27,66 +27,67 @@ import {supportsWebAnimation} from '@angular/platform-browser/testing/src/browse
|
||||
|
||||
it('should return ContentType.JSON', () => {
|
||||
const req = new Request(new RequestOptions({
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'application/json'})
|
||||
}) as any);
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'application/json'})
|
||||
}) as any);
|
||||
|
||||
expect(req.detectContentType()).toEqual(ContentType.JSON);
|
||||
});
|
||||
|
||||
it('should return ContentType.FORM', () => {
|
||||
const req = new Request(new RequestOptions({
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'application/x-www-form-urlencoded'})
|
||||
}) as any);
|
||||
const req = new Request(
|
||||
new RequestOptions({
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'application/x-www-form-urlencoded'})
|
||||
}) as any);
|
||||
|
||||
expect(req.detectContentType()).toEqual(ContentType.FORM);
|
||||
});
|
||||
|
||||
it('should return ContentType.FORM_DATA', () => {
|
||||
const req = new Request(new RequestOptions({
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'multipart/form-data'})
|
||||
}) as any);
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'multipart/form-data'})
|
||||
}) as any);
|
||||
|
||||
expect(req.detectContentType()).toEqual(ContentType.FORM_DATA);
|
||||
});
|
||||
|
||||
it('should return ContentType.TEXT', () => {
|
||||
const req = new Request(new RequestOptions({
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'text/plain'})
|
||||
}) as any);
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'text/plain'})
|
||||
}) as any);
|
||||
|
||||
expect(req.detectContentType()).toEqual(ContentType.TEXT);
|
||||
});
|
||||
|
||||
it('should return ContentType.BLOB', () => {
|
||||
const req = new Request(new RequestOptions({
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'application/octet-stream'})
|
||||
}) as any);
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'application/octet-stream'})
|
||||
}) as any);
|
||||
|
||||
expect(req.detectContentType()).toEqual(ContentType.BLOB);
|
||||
});
|
||||
|
||||
it('should not create a blob out of ArrayBuffer', () => {
|
||||
const req = new Request(new RequestOptions({
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: new ArrayBuffer(1),
|
||||
headers: new Headers({'content-type': 'application/octet-stream'})
|
||||
}) as any);
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: new ArrayBuffer(1),
|
||||
headers: new Headers({'content-type': 'application/octet-stream'})
|
||||
}) as any);
|
||||
|
||||
expect(req.detectContentType()).toEqual(ContentType.ARRAY_BUFFER);
|
||||
});
|
||||
@ -94,11 +95,11 @@ import {supportsWebAnimation} from '@angular/platform-browser/testing/src/browse
|
||||
|
||||
it('should return empty string if no body is present', () => {
|
||||
const req = new Request(new RequestOptions({
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'application/json'})
|
||||
}) as any);
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'application/json'})
|
||||
}) as any);
|
||||
|
||||
expect(req.text()).toEqual('');
|
||||
});
|
||||
|
Reference in New Issue
Block a user