我一直在尝试比较jasmine中的两个javascript对象。但是我遇到错误对象读取没有方法调用。

describe("AutoEditor", function() {

  var widgetList = ["widget1","widget2"];
  var oldEdgeStructure = {};
  oldEdgeStructure.SingleLink = [{"widget1":[{"EdgePosition":"s","WidgetID":"widget2"}]},
    {"widget2":[{"EdgePosition":"n","WidgetID":"widget1"}]}];

  it("read edges", function(done) {

    require(['auto-editor'], function(EdgeStructures) {
        var containerEl = $('#container');
        var edgeStructures = EdgeStructures.readEdges(widgetList,containerEl);
        expect(edgeStructures.SingleLink).toEqual(oldEdgeStructure.SingleLink);
        done();
    });

  });

});

最佳答案

收到错误消息是因为将div附加到DOM之后我没有在体内加载Edgestructures。米哈尔,你是对的。在加载DOM内容并解决问题之后,我刚刚在body标签中添加了用于加载库的script标签。

08-25 22:15