I'm trying to learn about unit testing and I found this overview by Ben Alman. On slide 23, he shows how a variable named actual
containing an object {a: 1}
is not equal to just the object itself. What does that mean? Aren't they the same value? How can the objects be different?
test("deepEqual", 7, function() {
var actual = {a: 1};
equal( actual, {a: 1}, "fails because objects are different");
deepEqual(actual, {a: 1}, "passes because objects are equivalent");
deepEqual(actual, {a: "1"}, "fails because '1' !== 1");
var a = $("body > *");
var b = $("body").children();
equal( a, b, "fails because jQuery objects are different");
deepEqual(a, b, "fails because jQuery objects are not equivalent");
equal( a.get(), b.get(), "fails because element arrays are different");
deepEqual(a.get(), b.get(), "passes because element arrays are equivalent");
});