From edc7de2d8472dcdec13ccb3a63ba9200a691021a Mon Sep 17 00:00:00 2001 From: onedionys Date: Fri, 8 Mar 2024 10:08:44 +0700 Subject: [PATCH] chore: add test package before publishing --- test/index.test.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/index.test.js diff --git a/test/index.test.js b/test/index.test.js new file mode 100644 index 0000000..cc2d1fa --- /dev/null +++ b/test/index.test.js @@ -0,0 +1,27 @@ +const assert = require('assert'); +const ProgressBar = require('../src/progress-bar'); + +describe('ProgressBar', function() { + describe('#getProgress()', function() { + it('should return 0 when no progress is set', function() { + const progressBar = new ProgressBar(100); + assert.strictEqual(progressBar.getProgress(), 0); + }); + + it('should return correct progress value', function() { + const progressBar = new ProgressBar(100); + progressBar.setProgress(50); + assert.strictEqual(progressBar.getProgress(), 50); + }); + + it('should throw an error for invalid progress value', function() { + const progressBar = new ProgressBar(100); + assert.throws(() => { + progressBar.setProgress(-1); + }, Error); + assert.throws(() => { + progressBar.setProgress(101); + }, Error); + }); + }); +});