Skip to content

Commit 02c2bb9

Browse files
Karan NagpalKaran Nagpal
authored andcommitted
fix tests and add size in bar
1 parent 2017d60 commit 02c2bb9

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

bin/helpers/zipUpload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const uploadSuits = (bsConfig, filePath, opts) => {
2525

2626
// create new progress bar
2727
let bar1 = new cliProgress.SingleBar({
28-
format: `${filePath} [{bar}] {percentage}% | ETA: {eta}s | Speed: {speed} kbps | Duration: {duration}s`,
28+
format: `${filePath} [{bar}] {percentage}% | ETA: {eta}s | Speed: {speed} kbps | Duration: {duration}s [${(size / 1000000).toFixed(2)} MB]`,
2929
hideCursor: true,
3030
});
3131

test/unit/bin/helpers/zipUpload.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,34 @@
22
const chai = require("chai"),
33
chaiAsPromised = require("chai-as-promised"),
44
sinon = require("sinon"),
5+
fs = require('fs'),
56
request = require("request");
67

78
const logger = require("../../../../bin/helpers/logger").winstonLogger,
89
constant = require('../../../../bin/helpers/constants');
910

10-
const rewire = require("rewire");
11+
const rewire = require("rewire"),
12+
cliProgress = require('cli-progress');
1113

1214
chai.use(chaiAsPromised);
1315
logger.transports["console.info"].silent = true;
1416

1517
describe("zipUpload", () => {
1618
let sandbox;
1719

20+
let barStub;
21+
1822
beforeEach(() => {
1923
sandbox = sinon.createSandbox();
24+
25+
barStub = {
26+
start: sinon.stub(),
27+
stop: sinon.stub(),
28+
update: sinon.stub(),
29+
on: sinon.stub(),
30+
}
31+
32+
sinon.stub(cliProgress, 'SingleBar').returns(barStub);
2033
});
2134

2235
afterEach(() => {
@@ -36,6 +49,11 @@ describe("zipUpload", () => {
3649
loggerStub = {
3750
info: sandbox.stub().returns(null)
3851
};
52+
sinon.stub(fs, 'lstatSync').returns({ size: 123 });
53+
});
54+
55+
afterEach(() => {
56+
fs.lstatSync.restore();
3957
});
4058

4159
it("reject with error", () => {

0 commit comments

Comments
 (0)