Skip to content

Commit

Permalink
[INTERNAL] projectPreprocessor: Refactor existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Mar 24, 2020
1 parent e7b4504 commit 282f126
Showing 1 changed file with 96 additions and 3 deletions.
99 changes: 96 additions & 3 deletions test/lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,12 @@ test("Project tree A with default YAMLs", (t) => {
});

test("Project tree B with inline configs", (t) => {
// Tree B depends on Library B which has a dependency to Library D
return projectPreprocessor.processTree(treeBWithInlineConfigs).then((parsedTree) => {
t.deepEqual(parsedTree, expectedTreeBWithInlineConfigs, "Parsed correctly");
});
});

test("Project tree Cycle A with inline configs", (t) => {
// Tree B depends on Library B which has a dependency to Library D
return projectPreprocessor.processTree(treeApplicationCycleA).then((parsedTree) => {
t.deepEqual(parsedTree, expectedTreeApplicationCycleA, "Parsed correctly");
});
Expand All @@ -560,6 +558,102 @@ test("Project with nested invalid dependencies", (t) => {
});
});

test("Application version in package.json data is missing", (t) => {
const tree = {
id: "application.a",
path: applicationAPath,
dependencies: [],
type: "application",
metadata: {
name: "xy"
}
};
return t.throws(projectPreprocessor.processTree(tree)).then((error) => {
t.is(error.message, "\"version\" is missing for project " + tree.id);
});
});

test("Library version in package.json data is missing", (t) => {
const tree = {
id: "library.d",
path: libraryDPath,
dependencies: [],
type: "library",
metadata: {
name: "library.d"
}
};
return t.throws(projectPreprocessor.processTree(tree)).then((error) => {
t.is(error.message, "\"version\" is missing for project " + tree.id);
});
});

test("specVersion: Missing version", (t) => {
const tree = {
id: "application.a",
path: "non-existent",
dependencies: [],
version: "1.0.0",
type: "application",
metadata: {
name: "xy"
}
};
return t.throws(projectPreprocessor.processTree(tree),
"No specification version defined for root project application.a",
"Rejected with error");
});

test("specVersion: Project with invalid version", async (t) => {
const tree = {
id: "application.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "0.9",
type: "application",
metadata: {
name: "xy"
}
};
await t.throws(projectPreprocessor.processTree(tree),
"Invalid specification version defined for project application.a: 0.9. " +
"See https://github.com/SAP/ui5-project/blob/master/docs/Configuration.md#specification-versions",
"Rejected with error");
});

test("specVersion: Project with valid version 0.1", async (t) => {
const tree = {
id: "application.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "0.1",
type: "application",
metadata: {
name: "xy"
}
};
const res = await projectPreprocessor.processTree(tree);
t.deepEqual(res.specVersion, "0.1", "Correct spec version");
});

test("specVersion: Project with valid version 1.0", async (t) => {
const tree = {
id: "application.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "1.0",
type: "application",
metadata: {
name: "xy"
}
};
const res = await projectPreprocessor.processTree(tree);
t.deepEqual(res.specVersion, "1.0", "Correct spec version");
});

/* ========================= */
/* ======= Test data ======= */

Expand Down Expand Up @@ -1543,7 +1637,6 @@ const expectedTreeApplicationCycleA = {

/* ======= /Test data ======= */
/* ========================= */

test("Application version in package.json data is missing", (t) => {
const tree = {
id: "application.a",
Expand Down

0 comments on commit 282f126

Please sign in to comment.