import { isObjectWithOnlyOne } from './ObjectWithOnlyOne'; import { objectWithKnownKey, objectWithUnknownKey, requiredKeys, } from './__test__'; describe('isObjectWithOnlyOne', (): void => { describe('given an object with a known key', (): void => { describe('when called with a set of required keys', (): void => { it('should be true', (): void => { expect(isObjectWithOnlyOne(objectWithKnownKey, requiredKeys)).toBe( true, ); }); }); describe('when called without a set of required keys', (): void => { it('should be true', (): void => { expect(isObjectWithOnlyOne(objectWithKnownKey)).toBe(true); }); }); }); describe('given an object with an unknown key', (): void => { describe('when called with a set of required keys', (): void => { it('should be false', (): void => { expect(isObjectWithOnlyOne(objectWithUnknownKey, requiredKeys)).toBe( false, ); }); }); describe('when called without a set of required keys', (): void => { it('should be true', (): void => { expect(isObjectWithOnlyOne(objectWithKnownKey)).toBe(true); }); }); }); });