qunit test error with equal and deepEqual

浪尽此生 提交于 2019-12-24 07:03:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!