2011-08-18 38 views
1

我試圖瞭解qunit測試qunit測試錯誤等於和deepEqual

爲什麼這個測試失敗?如果我比較每個屬性,是相同的...

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

    }); 
+0

哪個比較失敗? –

+0

我現在做兩個測試,兩個都失敗... –

回答

0

平等測試失敗吧?這是因爲它們是兩個不同的實例,即使它們包含相同的數據。例如,查看QUnit文檔here上的示例。

+0

我現在做兩個測試,兩個都失敗了...... –