Skip to content

Commit

Permalink
test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sebg-mio42 committed Jul 17, 2024
1 parent dd7e62f commit 6a5f689
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/import/FSHImporter.Instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,46 @@ describe('FSHImporter', () => {
);
expect(loggerSpy.getLastMessage('error')).toMatch(/File: File2\.fsh.*Line: 2 - 4\D*/s);
});

it('should not produce an error when encountering an instance with a name used by another instance in another file but has a unique versionId', () => {
const input1 = `
Instance: SomeInstance
InstanceOf: Patient
Title: "Instance"
* meta
* meta.versionId = "1"
`;

const input2 = `
Instance: SomeInstance
InstanceOf: Patient
Title: "Instance"
* meta
* meta.versionId = "2"
`;

const input3 = `
Instance: SomeInstance
InstanceOf: Patient
Title: "Instance"
`;

const result = importText([
new RawFSH(input1, 'File1.fsh'),
new RawFSH(input2, 'File2.fsh'),
new RawFSH(input3, 'File2.fsh')
]);
expect(result.reduce((sum, d2) => sum + d2.instances.size, 0)).toBe(3);
const instance1 = result[0].instances.get('SomeInstance');
const instance2 = result[1].instances.get('SomeInstance');
const instance3 = result[2].instances.get('SomeInstance');
expect(instance1.title).toBe('Instance');
expect(instance1.versionId).toBe('1');
expect(instance1.title).toBe('Instance');
expect(instance2.versionId).toBe('2');
expect(instance3.title).toBe('Instance');
expect(instance3.versionId).toBe(undefined);
});
});
});
});

0 comments on commit 6a5f689

Please sign in to comment.