Skip to content

Commit

Permalink
fix: get back to 100 percent coverage with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sshah-asymmetrik committed Apr 16, 2019
1 parent 7de9331 commit b9a59ef
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions packages/fhir-qb/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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",
);
});
});
});

0 comments on commit b9a59ef

Please sign in to comment.