angularjs repeater 无法读取 column

张映 发表于 2014-02-24

分类目录: nodejs/vue/js/jquery

标签:, , , ,

用e2e端到端的测试时,发现用expect(repeater('.phones li', 'Phone List').column('phone.images'))没法得到值,写了一个方法来获取

1,json片断

    "images": [
        "img/phones/nexus-s.0.jpg",
        "img/phones/nexus-s.1.jpg",
        "img/phones/nexus-s.2.jpg",
        "img/phones/nexus-s.3.jpg"
    ],
    "name": "Nexus S",

2,repeater读取测试

expect(repeater('.phones li', 'Phone List').column('phone.name')).
     toEqual(["Nexus S","Dell Venue"]);    //这样就可以的

expect(repeater('.phone-thumbs img', 'Phone List').column('phone.images')).
     toEqual(["Nexus S","Dell Venue"]);    //这样就不可以了

我测试了很多种方法,发现读取的都是[ ]。

3,用element结合query可以读取

it('should load mock widgets into correct order, by seq', function () {
  var promise = element('.phone-thumbs img').query(function (elements, done) {
      var seq = [];
      elements.each(function () {
          seq.push(angular.element(this).attr('src'));
      });
      done(null, seq);
  });
  expect(promise).toEqual([
      "img/phones/nexus-s.0.jpg",
      "img/phones/nexus-s.1.jpg",
      "img/phones/nexus-s.2.jpg",
      "img/phones/nexus-s.3.jpg"
  ]);
});


转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/jsjquery/1591.html