From b9a59ef9e8fd96548a370b0fd03b26f2b2856103 Mon Sep 17 00:00:00 2001 From: Sumeet Shah Date: Tue, 16 Apr 2019 14:10:41 -0400 Subject: [PATCH] fix: get back to 100 percent coverage with tests --- packages/fhir-qb/index.test.js | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/packages/fhir-qb/index.test.js b/packages/fhir-qb/index.test.js index 98b5997..a37fff3 100644 --- a/packages/fhir-qb/index.test.js +++ b/packages/fhir-qb/index.test.js @@ -3370,6 +3370,20 @@ describe('Mongo Tests', () => { expect(errors).toHaveLength(1); expect(errors[0].message).toContain("Unsupported request method 'PUT'"); }); + test('Should throw an error for unsupported modifiers', () => { + const request = { + method: 'GET', + query: { + 'foo:unsupportedModifier': 'bar', + }, + }; + const configs = { foo: { type: 'string', xpath: 'Resource.foo' } }; + let { errors } = qb.buildSearchQuery(request, configs); + expect(errors).toHaveLength(1); + expect(errors[0].message).toContain( + "Search modifier 'unsupportedModifier' is not currently supported", + ); + }); }); describe('Global Parameter Query Tests', () => { @@ -3409,6 +3423,10 @@ describe('Mongo Tests', () => { expect(errors).toHaveLength(0); expect(query).toEqual(expectedResult); }); + test('Should be able to initialize a new qb without supplying global parameters', () => { + const noGlobalQB = new QueryBuilder('fhir-qb-mongo'); + expect(noGlobalQB).toBeDefined(); + }); }); describe('Search Result Parameter Query Tests', () => { @@ -3427,21 +3445,4 @@ describe('Mongo Tests', () => { expect(query).toEqual(expectedResult); }); }); - - // TODO update this test when lookup funcitonality is added. - describe('Build Lookup Query Tests', () => { - test('Should throw an error if parameters are supplied in a way that requires building a lookup query', () => { - const request = { - method: 'GET', - query: { - 'foo:Patient': 'bar', - }, - }; - const configs = { foo: { type: 'string', xpath: 'Resource.foo' } }; - let { errors } = qb.buildSearchQuery(request, configs); - expect(errors[0].message).toContain( - "Search modifier 'Patient' is not currently supported", - ); - }); - }); });