Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineGautier committed Jan 13, 2025
1 parent 6659aba commit cd8296a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
13 changes: 13 additions & 0 deletions server/tests/integration/parser/loader.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { findPackageEntryPoints } from "../../../src/parser/loader";
import * as parser from "../../../src/parser/parser";
import { initializeTestModelicaJson } from "./utils";

Expand All @@ -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";
Expand Down
12 changes: 6 additions & 6 deletions server/tests/integration/parser/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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", () => {
Expand All @@ -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(
Expand All @@ -74,7 +75,6 @@ describe("Template wrapper class functionality", () => {

const templateJSON = nestedTemplate.getSystemTemplate();
const expectedOrder = [
"TestPackage.NestedTemplate",
"TestPackage.NestedTemplate.Subcategory",
];

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion server/tests/static-data/TestPackage/Template/package.mo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within TestPackage;
package Template "Test Template"
package Template "Test Template Package"
extends Modelica.Icons.Package;
end Template;

0 comments on commit cd8296a

Please sign in to comment.