1

我正在尝试理解 qunit 测试

为什么这个测试失败了?如果我比较每个属性,都一样...

    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);

    });
4

2 回答 2

1

https://forum.jquery.com/topic/why-deepequal-is-not-working-in-this-test#14737000002953407

于 2011-12-27T11:59:17.087 回答
0

平等测试失败了吗?这是因为它们是两个不同的实例,即使它们包含相同的数据。例如,在此处查看QUnit 文档中的示例。

于 2011-08-18T14:28:29.883 回答