Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/invoice_pdf/node_modules/isomorphic-fetch/test/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /*global fetch*/
"use strict";
require('../fetch-npm-node');
var expect = require('chai').expect;
var nock = require('nock');
var good = 'hello world. 你好世界。';
var bad = 'good bye cruel world. 再见残酷的世界。';
function responseToText(response) {
if (response.status >= 400) throw new Error("Bad server response");
return response.text();
}
describe('fetch', function() {
before(function() {
nock('https://mattandre.ws')
.get('/succeed.txt')
.reply(200, good);
nock('https://mattandre.ws')
.get('/fail.txt')
.reply(404, bad);
});
it('should be defined', function() {
expect(fetch).to.be.a('function');
});
it('should facilitate the making of requests', function(done) {
fetch('//mattandre.ws/succeed.txt')
.then(responseToText)
.then(function(data) {
expect(data).to.equal(good);
done();
})
.catch(done);
});
it('should do the right thing with bad requests', function(done) {
fetch('//mattandre.ws/fail.txt')
.then(responseToText)
.catch(function(err) {
expect(err.toString()).to.equal("Error: Bad server response");
done();
})
.catch(done);
});
});
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0089 ]-- |