Skip to content

Instantly share code, notes, and snippets.

@hackerwins
Created April 4, 2020 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackerwins/64660b2cc6662c6fa9328bc106e76b85 to your computer and use it in GitHub Desktop.
Save hackerwins/64660b2cc6662c6fa9328bc106e76b85 to your computer and use it in GitHub Desktop.
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