From 8055fa98139151275a3b6f514af6d5cbd0d1625c Mon Sep 17 00:00:00 2001 From: rjawesome Date: Tue, 6 Aug 2024 11:25:29 -0700 Subject: [PATCH] add more test cases for pf template generator --- .../unittest/pf_template_generator.test.ts | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/__test__/unittest/pf_template_generator.test.ts b/__test__/unittest/pf_template_generator.test.ts index 40a9d1c1..80aff452 100644 --- a/__test__/unittest/pf_template_generator.test.ts +++ b/__test__/unittest/pf_template_generator.test.ts @@ -12,10 +12,11 @@ describe('Test Pathfinder Template Generator', () => { categories: ['biolink:Disease'] }; - const templates = await generateTemplates(sub, un, obj); + const templatesWithUnCat = await generateTemplates(sub, un, obj); + const templatesWithoutUnCat = await generateTemplates(sub, {}, obj); // Template A - expect(templates[0]).toEqual({ + expect(templatesWithUnCat[0]).toEqual({ "nodes": { "creativeQuerySubject": { "categories": [ @@ -58,9 +59,10 @@ describe('Test Pathfinder Template Generator', () => { } } }); + expect(templatesWithoutUnCat[0]).toEqual(templatesWithUnCat[0]); // Template B - expect(templates[1]).toEqual({ + expect(templatesWithUnCat[1]).toEqual({ "nodes": { "creativeQuerySubject": { "categories": [ @@ -125,9 +127,10 @@ describe('Test Pathfinder Template Generator', () => { } } }); + expect(templatesWithoutUnCat[1]).toEqual(templatesWithUnCat[1]); // Template C - expect(templates[2]).toEqual({ + expect(templatesWithUnCat[2]).toEqual({ "nodes": { "creativeQuerySubject": { "categories": [ @@ -186,5 +189,22 @@ describe('Test Pathfinder Template Generator', () => { } } }); + expect(templatesWithoutUnCat[2]).toEqual(templatesWithUnCat[2]); + }); + + test('template with no predicates should not have predicate property', async () => { + const sub = { + categories: ['biolink:Drug'] + }; + const un = { + categories: ['biolink:Dummy'] + }; + const obj = { + categories: ['biolink:Drug'] + }; + + const templates = await generateTemplates(sub, un, obj); + expect(templates[0].edges.sub_un).not.toHaveProperty('predicates'); + expect(templates[0].edges.un_obj).not.toHaveProperty('predicates'); }); });