diff --git a/server/tests/integration/parser/loader.test.ts b/server/tests/integration/parser/loader.test.ts index e8a4c068..b77cd0c9 100644 --- a/server/tests/integration/parser/loader.test.ts +++ b/server/tests/integration/parser/loader.test.ts @@ -1,3 +1,4 @@ +import { findPackageEntryPoints } from "../../../src/parser/loader"; import * as parser from "../../../src/parser/parser"; import { initializeTestModelicaJson } from "./utils"; @@ -20,6 +21,18 @@ describe("Parser file loading", () => { expect(file.package).toBe("TestPackage"); }); + it("Finds package entry points", () => { + const packageName = "TestPackage"; + const entryPoints = findPackageEntryPoints(packageName); + expect(entryPoints.map(({className}) => className)).toEqual([ + 'TestPackage.NestedTemplate.Subcategory.SecondTemplate', + 'TestPackage.Template.TestTemplate', + 'TestPackage.NestedTemplate.Subcategory', + 'TestPackage.NestedTemplate', + 'TestPackage.Template' + ]); + }); + it("Discovers template files and project options", () => { const packageName = "TestPackage"; const projectOptionsClassName = "Buildings.Templates.Data.AllSystems"; diff --git a/server/tests/integration/parser/template.test.ts b/server/tests/integration/parser/template.test.ts index 7d52e973..6b8d9f88 100644 --- a/server/tests/integration/parser/template.test.ts +++ b/server/tests/integration/parser/template.test.ts @@ -23,7 +23,8 @@ describe("Template wrapper class functionality", () => { expect(templates.length).toBe(2); const systemTypes = [...getSystemTypes()]; - expect(systemTypes.length).toBe(3); + console.log(systemTypes); + expect(systemTypes.length).toBe(2); }); it("Templates have expected SystemTypes", () => { @@ -37,7 +38,7 @@ describe("Template wrapper class functionality", () => { const templateSystemTypes = template.getSystemTypes(); expect(templateSystemTypes.length).toBe(1); const nestedTemplateSystemTypes = nestedTemplate.getSystemTypes(); - expect(nestedTemplateSystemTypes.length).toBe(2); + expect(nestedTemplateSystemTypes.length).toBe(1); }); it("Templates output expected linkage schema for SystemTemplates", () => { @@ -64,8 +65,8 @@ describe("Template wrapper class functionality", () => { ); }); - it("Keeps system types in correct order", () => { - // The system types should match the directory order + it("There should be only one system type for each template", () => { + // Check that we only add the Modelica class name of the containing package. const templates = getTemplates(); const nestedTemplate = templates.find( @@ -74,7 +75,6 @@ describe("Template wrapper class functionality", () => { const templateJSON = nestedTemplate.getSystemTemplate(); const expectedOrder = [ - "TestPackage.NestedTemplate", "TestPackage.NestedTemplate.Subcategory", ]; @@ -128,7 +128,7 @@ describe("Template wrapper class functionality", () => { }); }); - it("Genereates path modifiers", () => { + it("Generates path modifiers", () => { const templates = getTemplates(); const template = templates.find( (t) => t.modelicaPath === TEMPLATE_PATH, diff --git a/server/tests/static-data/TestPackage/Template/package.mo b/server/tests/static-data/TestPackage/Template/package.mo index 80cae502..61848530 100644 --- a/server/tests/static-data/TestPackage/Template/package.mo +++ b/server/tests/static-data/TestPackage/Template/package.mo @@ -1,4 +1,4 @@ within TestPackage; -package Template "Test Template" +package Template "Test Template Package" extends Modelica.Icons.Package; end Template;