import { SubmissionCoreFormType } from '@sky-distribution/policy-service-interfaces/lib/core/SubmissionForm.type'; import { getEntityID, getEntityType } from '../../../services/Core/util/Core.util'; describe('Core.util', () => { describe('getEntityID()', () => { it('should return jobID', () => { // given const testInput = { jobID: '231231', } as SubmissionCoreFormType; expect(getEntityID(testInput)) .toEqual(testInput.jobID); }); it('should return quoteID', () => { // given const testInput = { quoteID: '231231', } as SubmissionCoreFormType; expect(getEntityID(testInput)) .toEqual(testInput.quoteID); }); it('should throw error if none identifiable fields present', () => { // given const testInput = {} as SubmissionCoreFormType; expect(() => getEntityID(testInput)) .toThrow('Could not retrieve entity identifier'); }); }); describe('getEntityType()', () => { it('should return \'renewal\'', () => { // given const testInput = { baseData: { jobType: 'renewal', }, } as SubmissionCoreFormType; expect(getEntityType(testInput)) .toEqual('renewal'); }); it('should return \'submission\'', () => { // given const testInput = { baseData: { jobType: 'submission', }, } as SubmissionCoreFormType; expect(getEntityType(testInput)) .toEqual('submission'); }); it('should throw error if not valid jobType provided', () => { // given const testInput = { baseData: { jobType: 'what?', }, } as SubmissionCoreFormType; expect(() => getEntityType(testInput)) .toThrow('No entity type for jobType (what?).'); }); }); });