问题
I'm Trying to understand qunit testing
Why is this test failing? If I compare every property, are the same ...
test("Get model equal", function () {
function getModel() {
function myModel() {
this.name = "";
this.address = "";
this.phone = "";
}
return new myModel();
}
var model1 = getModel();
var model2 = getModel();
equal(model1, model2);
});
test("Get model deepEqual", function () {
function getModel() {
function myModel() {
this.name = "";
this.address = "";
this.phone = "";
}
return new myModel();
}
var model1 = getModel();
var model2 = getModel();
deepEqual(model1, model2);
});
回答1:
https://forum.jquery.com/topic/why-deepequal-is-not-working-in-this-test#14737000002953407
回答2:
The equality test is failing right? That's because they are two different instances, even though they contain the same data. For example, look at the examples on the QUnit documentation here.
来源:https://stackoverflow.com/questions/7108922/qunit-test-error-with-equal-and-deepequal