Skip to content

Commit

Permalink
fix(#26): remove unnecessary comments and change fs_ to fs.fs in
Browse files Browse the repository at this point in the history
sync-fs.spec.js
  • Loading branch information
sugat009 committed Jan 28, 2024
1 parent 75966a7 commit 4a5dd9a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
3 changes: 0 additions & 3 deletions test/fn/csv-to-docs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ describe('csv-to-docs', function() {

const warnSpy = sinon.spy(warn);

// Test case 1: Directory is empty, no warning should be triggered
it('should not trigger warning if directory is empty', () => {
const dir = 'emptyDirectory';
const warningMsg = 'This is a warning message';
Expand All @@ -78,7 +77,6 @@ describe('csv-to-docs', function() {
expect(userPrompt.keyInYN.called).to.be.false;
});

// Test case 2: Directory is not empty, warning and user prompt should be triggered
it('should trigger warning and user prompt if directory is not empty', () => {
const dir = 'nonEmptyDirectory';
const warningMsg = 'This is a warning message';
Expand All @@ -92,7 +90,6 @@ describe('csv-to-docs', function() {
expect(userPrompt.keyInYN.calledWith('Are you sure you want to continue?')).to.be.true;
});

// Test case 3: User chooses not to continue, an error should be thrown
it('should throw an error if user chooses not to continue', () => {
const dir = 'nonEmptyDirectory';
const warningMsg = 'This is a warning message';
Expand Down
7 changes: 2 additions & 5 deletions test/lib/sync-fs.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const chai = require('chai');
const fs = require('../../src/lib/sync-fs');
// NOTE: be careful with the names, this one is the original fs module
// from nodeJS where the upper one is from our sync-fs module
const fs_ = require('fs');
const sinon = require('sinon');

const { expect } = chai;
Expand All @@ -28,7 +25,7 @@ describe('sync-fs', () => {
});

it('should return true for an empty directory', () => {
const readdirSyncStub = sinon.stub(fs_, 'readdirSync').returns([]);
const readdirSyncStub = sinon.stub(fs.fs, 'readdirSync').returns([]);

const emptyDir = 'path/to/empty/directory';
expect(fs.isDirectoryEmpty(emptyDir)).to.be.true;
Expand All @@ -37,7 +34,7 @@ describe('sync-fs', () => {
});

it('should return false for a non-empty directory', () => {
const readdirSyncStub = sinon.stub(fs_, 'readdirSync').returns(['file1', 'file2']);
const readdirSyncStub = sinon.stub(fs.fs, 'readdirSync').returns(['file1', 'file2']);

const nonEmptyDir = 'path/to/non-empty/directory';
expect(fs.isDirectoryEmpty(nonEmptyDir)).to.be.false;
Expand Down

0 comments on commit 4a5dd9a

Please sign in to comment.