瀏覽代碼

test for Path.set on Array

Evan You 11 年之前
父節點
當前提交
44f7a6d3a7
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      test/unit/specs/parsers/path_spec.js

+ 10 - 0
test/unit/specs/parsers/path_spec.js

@@ -136,6 +136,16 @@ describe('Path Parser', function () {
     expect(parent.a.b.c).toBe(123)
   })
 
+  it('set array', function () {
+    var target = {
+      a: []
+    }
+    target.a.$set = jasmine.createSpy('Array.$set')
+    var res = Path.set(target, 'a[1]', 123)
+    expect(res).toBe(true)
+    expect(target.a.$set).toHaveBeenCalledWith('1', 123)
+  })
+
   it('set invalid', function () {
     var res = Path.set({}, 'ab[c]d', 123)
     expect(res).toBe(false)