原本的測試檔如下:
expect(model).toBe { "opt1":true, "opt2":true, "opt3":true }
結果跑測試出現了下面的錯誤:
PhantomJS 1.9.8 (Mac OS X) tau-checkbox-model contructor should set candidates with given array FAILED
Expected { opt3t1 : true, opt2 : true, opt3 : true } to be { opt1 : true, opt2 : true, opt3 : true }.
AngularJS會在object中多加一些附屬屬性,導致jasmine比對時會視做不同的object。
將上面的測試改成
expect(angular.equals(model, { "opt1":true, "opt2":true, "opt3":true })).toBe true