m-ld-js
m-ld-js copied to clipboard
Should construct a nested object with a variable `@id`
test('constructs a nested object with a variable @id', async () => {
await api.write<Subject>({ '@id': 'fred', name: 'Fred', wife: { '@id': 'wilma' } });
await expect(api.read<Construct>({
'@construct': { '@id': 'fred', wife: { '@id': '?' } }
})).resolves.toMatchObject([{
'@id': 'fred', wife: { '@id': 'wilma' }
}]);
});
Instead, we get [{ '@id': 'fred', wife: { '@id': '?' } }]—the variable has shown up as a value in the result.
Note that using the variable as the entire value of wife in the @construct works correctly:
{ '@construct': { '@id': 'fred', wife: '?' } } => [{ '@id': 'fred', wife: { '@id': 'wilma' } }]