m-ld-js icon indicating copy to clipboard operation
m-ld-js copied to clipboard

Should construct a nested object with a variable `@id`

Open Peeja opened this issue 2 years ago • 0 comments

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' } }]

Peeja avatar Apr 06 '23 18:04 Peeja