diff --git a/packages/dhis2/src/Adaptor.js b/packages/dhis2/src/Adaptor.js index 519ad65fb..f7f73a4ce 100644 --- a/packages/dhis2/src/Adaptor.js +++ b/packages/dhis2/src/Adaptor.js @@ -904,7 +904,10 @@ export function dv(dataElement, value) { } export function shouldUseNewTracker(resourceType) { - return /^(trackedEntityInstances|enrollments|relationships|events|trackedEntities|tracker\/(enrollments|relationships|events|trackedEntities))$/.test( + // return /^(trackedEntityInstances|enrollments|relationships|events|trackedEntities|tracker\/(enrollments|relationships|events|trackedEntities))$/.test( + // resourceType + // ); + return /^(tracker\/|enrollments|relationships|events|trackedEntities)/.test( resourceType ); } diff --git a/packages/dhis2/test/index.test.js b/packages/dhis2/test/index.test.js index b2ebf32b1..46fb52997 100644 --- a/packages/dhis2/test/index.test.js +++ b/packages/dhis2/test/index.test.js @@ -149,22 +149,43 @@ describe('get', () => { }); }); -describe('helperfunctions', () => { +describe.only('helperfunctions', () => { it('should use the new tracker for enrollments', () => { const result = shouldUseNewTracker('enrollments'); expect(result).to.be.true; }); it('should use the new tracker for events', () => { + const result = shouldUseNewTracker('events'); + expect(result).to.be.true; + }); + + it('should use the new tracker for relationships', () => { + const result = shouldUseNewTracker('relationships'); + expect(result).to.be.true; + }); + + it('should use the new tracker for new tracker events', () => { const result = shouldUseNewTracker('tracker/events'); expect(result).to.be.true; }); + it('should use the new tracker for trackedEntityInstance', () => { + const result = shouldUseNewTracker('trackedEntityInstance'); + expect(result).to.be.true; + }); + it('should use the new tracker for trackedEntities', () => { const result = shouldUseNewTracker('trackedEntities'); expect(result).to.be.true; }); + it('should use the new tracker for new tracker generally', () => { + // This resource type does not exist but this function doesn't know that! + const result = shouldUseNewTracker('tracker/something'); + expect(result).to.be.true; + }); + it('should use the old API for dataValueSets', () => { const result = shouldUseNewTracker('dataValueSets'); expect(result).to.be.false;