Skip to content

Commit ffa43e2

Browse files
committed
chore: simplify tests
1 parent 59f68f3 commit ffa43e2

File tree

9 files changed

+32
-595
lines changed

9 files changed

+32
-595
lines changed

dist/js/flavorMixin.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
22
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
33
import type { FlavorSchema } from "@mat3ra/esse/dist/js/types";
44
import { type FlavorSchemaMixin } from "./generated/FlavorSchemaMixin";
5-
export type FlavorMixin = FlavorSchemaMixin & {};
5+
export type FlavorMixin = FlavorSchemaMixin;
66
export type FlavorStaticMixin = {
77
jsonSchema: FlavorSchema;
88
};

dist/js/flavorMixin.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
66
exports.flavorMixin = flavorMixin;
77
const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
88
const FlavorSchemaMixin_1 = require("./generated/FlavorSchemaMixin");
9-
// TODO: should we add fields from esse schema (executableId, executableName, applicationName)?
10-
function flavorPropertiesMixin(item) {
11-
// @ts-expect-error
12-
const properties = {
13-
// TODO: there is no "isMultiMaterial" field in the schema; should we add it?
14-
// get disableRenderMaterials() {
15-
// return this.prop("isMultiMaterial", false);
16-
// },
17-
// TODO: do we actually use this method anywhere?
18-
// getInputAsRenderedTemplates(context: Record<string, unknown>) {
19-
// return this.input?.map((template) => {
20-
// if (template && typeof template === "object" && "getRenderedJSON" in template) {
21-
// return template.getRenderedJSON(context);
22-
// }
23-
// return template;
24-
// });
25-
// },
26-
};
27-
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
28-
return properties;
29-
}
309
function flavorStaticMixin(Flavor) {
3110
const properties = {
3211
get jsonSchema() {
@@ -37,6 +16,5 @@ function flavorStaticMixin(Flavor) {
3716
}
3817
function flavorMixin(Item) {
3918
(0, FlavorSchemaMixin_1.flavorSchemaMixin)(Item.prototype);
40-
flavorPropertiesMixin(Item.prototype);
4119
flavorStaticMixin(Item);
4220
}

package-lock.json

Lines changed: 29 additions & 159 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@
4343
"license": "Apache-2.0",
4444
"homepage": "https://github.com/Exabyte-io/ade",
4545
"dependencies": {
46-
"@types/react-jsonschema-form": "^1.7.13",
47-
"lodash": "^4.17.21",
48-
"nunjucks": "^3.2.4",
49-
"react-jsonschema-form": "^1.8.1"
46+
"lodash": "^4.17.21"
5047
},
5148
"devDependencies": {
5249
"@babel/eslint-parser": "^7.16.3",
@@ -57,7 +54,6 @@
5754
"@mat3ra/made": "2025.7.15-0",
5855
"@mat3ra/standata": "2025.10.1-0",
5956
"@mat3ra/tsconfig": "2024.6.3-0",
60-
"@types/nunjucks": "^3.2.6",
6157
"@typescript-eslint/eslint-plugin": "^5.9.1",
6258
"@typescript-eslint/parser": "^5.9.1",
6359
"chai": "^4.3.4",

src/js/flavorMixin.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,7 @@ import type { FlavorSchema } from "@mat3ra/esse/dist/js/types";
55

66
import { type FlavorSchemaMixin, flavorSchemaMixin } from "./generated/FlavorSchemaMixin";
77

8-
export type FlavorMixin = FlavorSchemaMixin & {
9-
// getInputAsRenderedTemplates: (context: Record<string, unknown>) => Record<string, unknown>[];
10-
};
11-
12-
// TODO: should we add fields from esse schema (executableId, executableName, applicationName)?
13-
function flavorPropertiesMixin(item: InMemoryEntity & FlavorSchemaMixin) {
14-
// @ts-expect-error
15-
const properties: FlavorMixin & InMemoryEntity & FlavorSchemaMixin = {
16-
// TODO: there is no "isMultiMaterial" field in the schema; should we add it?
17-
// get disableRenderMaterials() {
18-
// return this.prop("isMultiMaterial", false);
19-
// },
20-
// TODO: do we actually use this method anywhere?
21-
// getInputAsRenderedTemplates(context: Record<string, unknown>) {
22-
// return this.input?.map((template) => {
23-
// if (template && typeof template === "object" && "getRenderedJSON" in template) {
24-
// return template.getRenderedJSON(context);
25-
// }
26-
// return template;
27-
// });
28-
// },
29-
};
30-
31-
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
32-
33-
return properties;
34-
}
8+
export type FlavorMixin = FlavorSchemaMixin;
359

3610
function flavorStaticMixin(Flavor: Constructor<InMemoryEntity>) {
3711
const properties: FlavorStaticMixin = {
@@ -49,6 +23,5 @@ export type FlavorStaticMixin = {
4923

5024
export function flavorMixin(Item: Constructor<InMemoryEntity>) {
5125
flavorSchemaMixin(Item.prototype);
52-
flavorPropertiesMixin(Item.prototype);
5326
flavorStaticMixin(Item);
5427
}

tests/js/application.test.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,7 @@ import { expect } from "chai";
44
import Application from "../../src/js/Application";
55

66
describe("Application", () => {
7-
const obj = { name: "espresso" };
8-
9-
it("can be created", () => {
10-
const app = new Application(obj);
11-
expect(app.name).to.equal("espresso");
12-
});
13-
147
describe("applicationMixin properties", () => {
15-
let app: Application;
16-
17-
beforeEach(() => {
18-
app = new Application(obj);
19-
});
20-
21-
describe("hasAdvancedComputeOptions property", () => {
22-
it("should return true when set", () => {
23-
app.setProp("hasAdvancedComputeOptions", true);
24-
expect(app.hasAdvancedComputeOptions).to.be.true;
25-
});
26-
});
27-
28-
describe("isLicensed property", () => {
29-
it("should return true when set", () => {
30-
app.setProp("isLicensed", true);
31-
expect(app.isLicensed).to.be.true;
32-
});
33-
});
34-
358
describe("isUsingMaterial property", () => {
369
it("should return true for vasp application", () => {
3710
const vaspApp = new Application({ name: "vasp" });
@@ -56,15 +29,6 @@ describe("Application", () => {
5629
});
5730

5831
describe("applicationStaticMixin properties", () => {
59-
it("should have defaultConfig with correct structure", () => {
60-
const config = Application.defaultConfig;
61-
expect(config).to.have.property("name", "espresso");
62-
expect(config).to.have.property("shortName", "qe");
63-
expect(config).to.have.property("version", "6.3");
64-
expect(config).to.have.property("summary", "Quantum ESPRESSO");
65-
expect(config).to.have.property("build", "GNU");
66-
});
67-
6832
it("should return the complete defaultConfig object", () => {
6933
expect(Application.defaultConfig).to.deep.equal({
7034
name: "espresso",

tests/js/executable.test.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable no-unused-expressions */
22
import { expect } from "chai";
33

4-
import ApplicationRegistry from "../../src/js/ApplicationRegistry";
54
import Executable from "../../src/js/Executable";
65

76
describe("Executable", () => {
@@ -13,55 +12,6 @@ describe("Executable", () => {
1312
expect(json).to.have.property("schemaVersion");
1413
});
1514

16-
it("should find executable via ApplicationRegistry and validate JSON structure", () => {
17-
// Find an executable using ApplicationRegistry
18-
const executable = ApplicationRegistry.getExecutableByName("espresso", "pw.x");
19-
20-
// Verify we got a valid executable
21-
expect(executable).to.be.instanceOf(Executable);
22-
expect(executable.name).to.equal("pw.x");
23-
24-
// Get JSON representation
25-
const json = executable.toJSON();
26-
27-
// Validate JSON structure contains expected properties
28-
expect(json).to.be.an("object");
29-
expect(json).to.have.property("name");
30-
expect(json.name).to.equal("pw.x");
31-
32-
// Verify core executable properties
33-
expect(json).to.have.property("isDefault");
34-
expect(json.isDefault).to.be.a("boolean");
35-
36-
expect(json).to.not.have.property("flavors");
37-
38-
// Verify arrays of configuration data
39-
expect(json).to.have.property("monitors");
40-
expect(json.monitors).to.be.an("array");
41-
42-
expect(json).to.have.property("results");
43-
expect(json.results).to.be.an("array");
44-
45-
// The JSON should be comprehensive
46-
expect(Object.keys(json).length).to.be.greaterThan(2);
47-
});
48-
49-
describe("executableMixin properties", () => {
50-
let executable: Executable;
51-
beforeEach(() => {
52-
executable = new Executable({ name: "test_exec" });
53-
});
54-
55-
it("should get default applicationId as empty array", () => {
56-
expect(executable.applicationId).to.deep.equal([]);
57-
});
58-
59-
it("should set and get applicationId", () => {
60-
executable.applicationId = ["app1", "app2"];
61-
expect(executable.applicationId).to.deep.equal(["app1", "app2"]);
62-
});
63-
});
64-
6515
describe("executableStaticMixin", () => {
6616
it("should have jsonSchema property", () => {
6717
expect(Executable.jsonSchema).to.exist;

tests/js/flavor.test.ts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -22,71 +22,6 @@ describe("Flavor", () => {
2222
]);
2323
});
2424

25-
describe("flavorMixin properties", () => {
26-
let flavor: Flavor;
27-
beforeEach(() => {
28-
flavor = new Flavor({ name: "test_flavor" });
29-
});
30-
31-
it("should have default input as empty array", () => {
32-
expect(flavor.input).to.deep.equal([]);
33-
});
34-
35-
it("should return input when set", () => {
36-
const input = [{ name: "param1" }, { name: "param2" }];
37-
flavor.setProp("input", input);
38-
expect(flavor.input).to.deep.equal(input);
39-
});
40-
41-
it("should have executableId as empty string by default", () => {
42-
expect(flavor.executableId).to.equal("");
43-
});
44-
45-
it("should return executableId when set", () => {
46-
flavor.setProp("executableId", "exec123");
47-
expect(flavor.executableId).to.equal("exec123");
48-
});
49-
50-
it("should have executableName as empty string by default", () => {
51-
expect(flavor.executableName).to.equal("");
52-
});
53-
54-
it("should return executableName when set", () => {
55-
flavor.setProp("executableName", "pw");
56-
expect(flavor.executableName).to.equal("pw");
57-
});
58-
59-
it("should have applicationName as empty string by default", () => {
60-
expect(flavor.applicationName).to.equal("");
61-
});
62-
63-
it("should return applicationName when set", () => {
64-
flavor.setProp("applicationName", "espresso");
65-
expect(flavor.applicationName).to.equal("espresso");
66-
});
67-
68-
it("should have supportedApplicationVersions as undefined by default", () => {
69-
expect(flavor.supportedApplicationVersions).to.be.undefined;
70-
});
71-
72-
it("should return supportedApplicationVersions when set", () => {
73-
flavor.setProp("supportedApplicationVersions", ["6.3", "7.0"]);
74-
expect(flavor.supportedApplicationVersions).to.deep.equal(["6.3", "7.0"]);
75-
});
76-
77-
// Added with LLM to help with coverage
78-
// it("should handle getInputAsRenderedTemplates with different template types", () => {
79-
// const mockTemplate = { getRenderedJSON: () => ({ rendered: true }) };
80-
// const simpleTemplate = { name: "simple" };
81-
// flavor.setProp("input", [mockTemplate, simpleTemplate]);
82-
83-
// const result = flavor.getInputAsRenderedTemplates({});
84-
// expect(result).to.have.length(2);
85-
// expect(result[0]).to.deep.equal({ rendered: true });
86-
// expect(result[1]).to.deep.equal({ name: "simple" });
87-
// });
88-
});
89-
9025
describe("flavorStaticMixin", () => {
9126
it("should have jsonSchema property", () => {
9227
expect(Flavor.jsonSchema).to.exist;

0 commit comments

Comments
 (0)