Created
April 4, 2020 09:39
-
-
Save hackerwins/64660b2cc6662c6fa9328bc106e76b85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it.only('can remove element by ID in array', function() { | |
const doc = Document.create('test-col', 'test-doc'); | |
assert.equal('{}', doc.toSortedJSON()); | |
let toDelete; | |
doc.update((root) => { | |
root['list'] = []; | |
root['list'].push(1); | |
root['list'].push(2); | |
toDelete = root['list'].push(3); | |
root['list'].push(4); | |
}, 'set {"list":[1,2,3,4]}'); | |
assert.equal('{"list":[1,2,3,4]}', doc.toSortedJSON()); | |
doc.update((root) => { | |
root['list'].removeByID(toDelete.getID()); | |
}, 'remove 3'); | |
assert.equal('{"list":[1,2,4]}', doc.toSortedJSON()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment