Browse Source

test for Path.set on Array

Evan You 11 years ago
parent
commit
44f7a6d3a7
1 changed files with 10 additions and 0 deletions
  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)