forked from AlaSQL/alasql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(utils.isNode) Incompatibility of utils.isNode Function with signa…
…l-exit AlaSQL#1889
- Loading branch information
vishal diyora
authored and
vishal diyora
committed
Mar 16, 2024
1 parent
d3faf32
commit 7e42397
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
if (typeof exports === 'object') { | ||
var assert = require('assert'); | ||
var alasql = require('..'); | ||
} | ||
|
||
var test = '1889'; // insert test file number | ||
|
||
describe('Test 1889 - Ensure utils.isNode handles node and non-Node environments', function () { | ||
let originalProcess; | ||
|
||
before(function() { | ||
// Store the original process object | ||
originalProcess = global.process; | ||
}); | ||
|
||
after(function() { | ||
// Restore the original process object after all tests | ||
global.process = originalProcess; | ||
}); | ||
|
||
it('Positive: Detect Node environment', function () { | ||
// No modification needed here, running in actual Node.js environment | ||
const isNode = alasql.utils.isNode; | ||
assert.strictEqual(isNode, true, 'utils.isNode should return true in a Node.js environment'); | ||
}); | ||
|
||
it('Negative: Detect Node environment', function () { | ||
// Temporarily override the global process object | ||
global.process = null; | ||
|
||
delete require.cache[require.resolve('..')]; | ||
const reloadedAlasql = require('..'); | ||
|
||
const isNodeAfterModification = reloadedAlasql.utils.isNode; | ||
assert.strictEqual(isNodeAfterModification, false, 'utils.isNode should return true in a Node.js environment'); | ||
}); | ||
|
||
}); |