I have a module that I want to test:
var array = []; //<--- mobule local array
var Deleter = {
DeleteNumb: function(number) {
console.log("TEST", array); //<--- Console
var index = array.indexOf(number);
if(index != -1) {
array.splice(index, 1);
}
}
};
module.exports = Deleter;
And I have a test file throught which I am trying to test this file:
var expect = require("chai").expect;
var Deleter = require("../DELETE.js");
describe("Testing Deleter", function() {
it("DeleteNumb", function() {
var array = [1,2,3,4,5]; // <--- test arrray
Deleter.DeleteNumb(3);
expect(array).to.be.length(4);
});
});
I want to test if an array variable is indeed spliced if I call DeleteNumb function. But in the console I get: "TEST: [ ]", because array variable that is local to the module being tested is indeed empty. My question is how to modify that local array for my testing? I do not want to parse the array as an argument for DeleteNumb. Thanks in advance.