Support recursive temporary id
Closed this issue · 0 comments
NickCaminer commented
it('should support the same recursive ID', ()=>{
//#region class
@Node()
class Cell{
@Uid()
uid: string;
@Predicate({ name: 'from_row', type: () => Row })
fromRow: Predicate<Row>;
@Predicate({ name: 'from_column', type: () => Column })
fromColumn: Predicate<Column>;
}
@Node()
class Row{
@Uid()
uid: string;
@Predicate({ name: 'has_cell', type: () => Cell })
hasCell: Predicate<Cell>;
}
@Node()
class Column{
@Uid()
uid: string;
@Predicate({ name: 'has_cell', type: () => Cell })
hasCell: Predicate<Cell>;
}
//#endregion
const cell = new Cell();
const row = new Row();
const column = new Column();
cell.fromRow.add(row);
cell.fromColumn.add(column);
row.hasCell.add(cell);
const rq = MutationBuilder.getSetNQuads(row);
const rowId = rq.nodeMap.get(row)?.value;
const fromRowId = (rq.quads as Quad[]).find(r=>r.predicate.id === 'from_row')?.object.value;
expect(rowId).toEqual(fromRowId);
});