I have seen some helpful posts on equal and deepEqual, but I still don't understand why this mocha test is failing.
describe('remove(thing)', function(){
it('should remove the word from the wordlist if it is there', function(){
var wordlist1 = new Wordlist('unit1');
wordlist1.add("bird");
wordlist1.add("elephant");
wordlist1.add("cat");
wordlist1.add("dog");
assert.equal(wordlist1.find("bird"), 0); //passes
wordlist1.remove('bird');
assert.equal(wordlist1.words[0], "elephant"); //passes
assert.equal(wordlist1.words[1], "cat"); //passes
assert.equal(wordlist1.words[2], "dog"); //passes
var thingie = ["elephant", "cat", "dog"];
assert.deepEqual(wordlist1.words, thingie); //fails
})
});
I have tried using single quotes rather than double quotes and changing the spacing around the brackets, but all of them tell me the same thing:
AssertionError: ["elephant","cat","dog"] deepEqual ["elephant","cat","dog"] <Click to see difference>
When I click to see the difference, WebStorm tells me that the two things are identical. Why does this test fail in spite of me using deepEqual if the two arrays have identical contents? If it's because they are strings, what approach can be used to check the equality of the arrays of strings?