Remove duplicated tests (#873)
* move some of the previously deleted tests to the external-encoding.js
This commit is contained in:
parent
1fdc218a64
commit
e17cefbb90
|
@ -5,7 +5,7 @@ const {expect} = chai;
|
|||
|
||||
describe('external encoding', () => {
|
||||
describe('data uri', () => {
|
||||
it('should accept data uri', () => {
|
||||
it('should accept base64-encoded gif data uri', () => {
|
||||
return fetch('data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=').then(r => {
|
||||
expect(r.status).to.equal(200);
|
||||
expect(r.headers.get('Content-Type')).to.equal('image/gif');
|
||||
|
@ -16,6 +16,15 @@ describe('external encoding', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should accept data uri with specified charset', async () => {
|
||||
const r = await fetch('data:text/plain;charset=UTF-8;page=21,the%20data:1234,5678');
|
||||
expect(r.status).to.equal(200);
|
||||
expect(r.headers.get('Content-Type')).to.equal('text/plain;charset=UTF-8;page=21');
|
||||
|
||||
const b = await r.text();
|
||||
expect(b).to.equal('the data:1234,5678');
|
||||
});
|
||||
|
||||
it('should accept data uri of plain text', () => {
|
||||
return fetch('data:,Hello%20World!').then(r => {
|
||||
expect(r.status).to.equal(200);
|
||||
|
|
33
test/main.js
33
test/main.js
|
@ -2125,37 +2125,4 @@ describe('node-fetch', () => {
|
|||
|
||||
fetch(url).then(res => expect(res.url).to.equal(`${base}m%C3%B6bius`));
|
||||
});
|
||||
|
||||
describe('data uri', () => {
|
||||
const dataUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=';
|
||||
|
||||
const invalidDataUrl = 'data:@@@@';
|
||||
|
||||
it('should accept data uri', () => {
|
||||
return fetch(dataUrl).then(r => {
|
||||
console.assert(r.status === 200);
|
||||
console.assert(r.headers.get('Content-Type') === 'image/gif');
|
||||
|
||||
return r.buffer().then(b => {
|
||||
console.assert(b instanceof Buffer);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept data uri 2', async () => {
|
||||
const r = await fetch('data:text/plain;charset=UTF-8;page=21,the%20data:1234,5678');
|
||||
expect(r.status).to.equal(200);
|
||||
expect(r.headers.get('Content-Type')).to.equal('text/plain;charset=UTF-8;page=21');
|
||||
|
||||
const b = await r.text();
|
||||
expect(b).to.equal('the data:1234,5678');
|
||||
});
|
||||
|
||||
it('should reject invalid data uri', () => {
|
||||
return fetch(invalidDataUrl).catch(error => {
|
||||
console.assert(error);
|
||||
console.assert(error.message.includes('invalid URL'));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue