mirror of
https://github.com/tenrok/axios.git
synced 2026-06-11 18:02:32 +03:00
fix(adapter): fix progress event emitting; (#6518)
This commit is contained in:
@@ -11,12 +11,25 @@ See your console
|
||||
|
||||
data.fill(123);
|
||||
|
||||
axios.post('http://httpbin.org/post', data, {
|
||||
onUploadProgress: console.log,
|
||||
onDownloadProgress: console.log,
|
||||
}).then(data=> {
|
||||
console.log(`Done: `, data);
|
||||
}).catch(console.warn);
|
||||
console.log('Starting...');
|
||||
|
||||
(async() => {
|
||||
await axios.post('http://httpbin.org/post', data, {
|
||||
adapter: 'xhr',
|
||||
onUploadProgress: (e) => console.log('xhr upload', e),
|
||||
onDownloadProgress: (e) => console.log('xhr download', e),
|
||||
}).then(data=> {
|
||||
console.log(`Done: `, data);
|
||||
}).catch(e => console.warn('xhr', e));
|
||||
|
||||
await axios.post('https://httpbin.org/post', data, {
|
||||
adapter: 'fetch',
|
||||
onUploadProgress: (e) => console.log('fetch upload', e),
|
||||
onDownloadProgress: (e) => console.log('fetch download', e)
|
||||
}).then(data=> {
|
||||
console.log(`Done: `, data);
|
||||
}).catch(e => console.warn('fetch', e));
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1919,6 +1919,7 @@ describe('supports http with nodejs', function () {
|
||||
describe('progress', function () {
|
||||
describe('upload', function () {
|
||||
it('should support upload progress capturing', async function () {
|
||||
this.timeout(15000);
|
||||
server = await startHTTPServer({
|
||||
rate: 100 * 1024
|
||||
});
|
||||
@@ -1943,6 +1944,7 @@ describe('supports http with nodejs', function () {
|
||||
|
||||
const {data} = await axios.post(LOCAL_SERVER_URL, readable, {
|
||||
onUploadProgress: ({loaded, total, progress, bytes, upload}) => {
|
||||
console.log('onUploadProgress', loaded, '/', total);
|
||||
samples.push({
|
||||
loaded,
|
||||
total,
|
||||
@@ -1975,6 +1977,8 @@ describe('supports http with nodejs', function () {
|
||||
|
||||
describe('download', function () {
|
||||
it('should support download progress capturing', async function () {
|
||||
this.timeout(15000);
|
||||
|
||||
server = await startHTTPServer({
|
||||
rate: 100 * 1024
|
||||
});
|
||||
@@ -1999,6 +2003,7 @@ describe('supports http with nodejs', function () {
|
||||
|
||||
const {data} = await axios.post(LOCAL_SERVER_URL, readable, {
|
||||
onDownloadProgress: ({loaded, total, progress, bytes, download}) => {
|
||||
console.log('onDownloadProgress', loaded, '/', total);
|
||||
samples.push({
|
||||
loaded,
|
||||
total,
|
||||
@@ -2114,7 +2119,7 @@ describe('supports http with nodejs', function () {
|
||||
}]`
|
||||
);
|
||||
|
||||
const progressTicksRate = 2;
|
||||
const progressTicksRate = 3;
|
||||
const expectedProgress = ((i + skip) / secs) / progressTicksRate;
|
||||
|
||||
assert.ok(
|
||||
|
||||
Reference in New Issue
Block a user