Skip to content

Instantly share code, notes, and snippets.

@nornagon
Created May 13, 2011 23:54
Show Gist options
  • Save nornagon/971522 to your computer and use it in GitHub Desktop.
Save nornagon/971522 to your computer and use it in GitHub Desktop.
test.deepEqual ['x',4], type._transformPath(['x',3], {p:['x',0], li:0})
test.deepEqual ['x',3], type._transformPath(['x',3], {p:['x',5], li:0})
test.deepEqual ['x',3], type._transformPath(['x',3], {p:['x',0,'x'], li:0})
test.deepEqual ['x',3,'x'], type._transformPath(['x',3,'x'], {p:['x',5], li:0})
test.deepEqual ['x',4,'x'], type._transformPath(['x',3,'x'], {p:['x',0], li:0})
@josephg
Copy link

josephg commented May 14, 2011

'Paths are bumped when list elements are inserted or removed': (test) ->
    test.deepEqual [{p:[2, 200], si:'hi'}], type.transform [{p:[1, 200], si:'hi'}], [{p:[0], li:'x'}], 'client'
    test.deepEqual [{p:[1, 200], si:'hi'}], type.transform [{p:[0, 200], si:'hi'}], [{p:[0], li:'x'}], 'client'
    test.deepEqual [{p:[0, 200], si:'hi'}], type.transform [{p:[0, 200], si:'hi'}], [{p:[1], li:'x'}], 'client'

    test.deepEqual [{p:[0, 200], si:'hi'}], type.transform [{p:[1, 200], si:'hi'}], [{p:[0], ld:'x'}], 'client'
    test.deepEqual [{p:[0, 200], si:'hi'}], type.transform [{p:[0, 200], si:'hi'}], [{p:[1], ld:'x'}], 'client'

    test.done()


'Ops on a moved element move with the element': (test) ->
    test.deepEqual [{p:[10], ld:'x'}], type.transform [{p:[4], ld:'x'}], [{p:[4], lm:10}], 'client'
    test.deepEqual [{p:[10, 1], si:'a'}], type.transform [{p:[4, 1], si:'a'}], [{p:[4], lm:10}], 'client'
    test.done()


'Ops on a moved element move with the element': (test) ->
    test.deepEqual [{p:['k2'], od:'x'}], type.transform [{p:['k1'], od:'x'}], [{p:['k1'], om:'k2'}], 'client'
    test.deepEqual [{p:['k2', 1], si:'a'}], type.transform [{p:['k1', 1], si:'a'}], [{p:['k1'], om:'k2'}], 'client'
    test.done()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment