Skip to content

Commit

Permalink
WIP- Recreated MWE from #46
Browse files Browse the repository at this point in the history
  • Loading branch information
umesh-timalsina committed Oct 6, 2022
1 parent 4673721 commit 3e45a25
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/common/JSONImporter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,50 @@ describe('JSONImporter', function () {
const [schemaBp] = schemaAp.children;
assert.equal(schemaBp.pointers.base, core.getGuid(nodeB));
});

it('should recreate deleted nodes on setting pointers and assign proper guid', async function() {
const fco = await core.loadByPath(root, '/1');
const parent = core.createNode({
parent: root,
base: fco
});

const child1 = core.createNode({
parent: parent,
base: fco
});
core.setAttribute(child1, 'name', 'child1');

const child2 = core.createNode({
parent: parent,
base: fco
});
core.setAttribute(child2, 'name', 'child2');


const child3 = core.createNode({
parent: parent,
base: fco
});
core.setAttribute(child3, 'name', 'child3');

core.setPointer(child1, 'sibling', child2);

const state = await importer.toJSON(parent);

const deletedPointerGuid = core.getGuid(child3);

const child1State = state.children.find(child => child.attributes.name === 'child1')
child1State.pointers.sibling = deletedPointerGuid;

core.deleteNode(child3);

await importer.apply(parent, state);
const pointer = await core.loadPointer(child1, 'sibling');

assert(core.getGuid(pointer) === deletedPointerGuid, core.getGuid(pointer) + '/' + deletedPointerGuid);
});

});

describe('pointer meta', function() {
Expand Down

0 comments on commit 3e45a25

Please sign in to comment.