1 const { countEntities } = require('./count-entities');
3 describe('countEntities', () => {
5 { description: 'I only have one value!' },
6 { npi: '2.16.840.1.113883.4.6', other: true },
7 { code: '409073007', other: false },
8 { extension: '45665', other: 10 },
9 { id: '47', other: null },
10 { date: '2023-09-17', other: {} },
11 { use: 'work place', other: [] },
12 { type: 'primary home', other: () => true },
13 ])('should return 1 if the input represents a single entity', (input) => {
14 expect(countEntities(input)).toEqual(1);
18 [[{ a: 1 }, { b: 2 }, { c: 3 }], 3],
21 description: `I have multiple values inside, but none has an entity key!`,
27 'should return the number of enumerable keys in the object if the input does not represent a single entity',
29 expect(countEntities(input)).toEqual(result);
33 test.each([null, undefined, 10, true, 'OpenEMR', () => {}])(
34 'should return zero if the input is %p',
36 expect(countEntities(input)).toEqual(0);
40 it('should return zero if the input is an empty array', () => {
41 expect(countEntities([])).toEqual(0);