-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to increase coverage Fix naming in manifest.json file of library H Co-authored-by: Matthias Osswald <[email protected]>
- Loading branch information
1 parent
4c81be8
commit 7416a97
Showing
8 changed files
with
180 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const test = require("ava"); | ||
|
||
const ModuleInfo = require("../../../../lib/lbt/resources/ModuleInfo"); | ||
|
||
test("ModuleInfo: constructor", async (t) => { | ||
const moduleInfo = new ModuleInfo("myName"); | ||
t.falsy(moduleInfo.exposedGlobals, "exposedGlobals is not set"); | ||
t.falsy(moduleInfo.format, "format is not set"); | ||
t.falsy(moduleInfo.description, "description is not set"); | ||
t.false(moduleInfo.requiresTopLevelScope, "requiresTopLevelScope is false"); | ||
t.false(moduleInfo.rawModule, "rawModule is false"); | ||
t.false(moduleInfo.dynamicDependencies, "dynamicDependencies is false"); | ||
t.deepEqual(moduleInfo.subModules, [], "submodules are empty"); | ||
}); | ||
|
||
test("ModuleInfo: addSubModule", async (t) => { | ||
// setup | ||
const moduleInfo = new ModuleInfo("myName"); | ||
moduleInfo.addDependency("otherModule", false); | ||
const otherModuleInfo = new ModuleInfo("otherModule"); | ||
otherModuleInfo.addDependency("unknownModule", false); | ||
otherModuleInfo.dynamicDependencies = true; | ||
|
||
// action | ||
moduleInfo.addSubModule(otherModuleInfo); | ||
|
||
// expectation | ||
t.true(moduleInfo.dynamicDependencies, "dynamicDependencies is set"); | ||
t.deepEqual(moduleInfo.subModules, ["otherModule"], "submodule is set"); | ||
t.deepEqual(moduleInfo.dependencies, ["unknownModule"], "unknownModule dependency is copied over"); | ||
}); | ||
|
||
test("ModuleInfo: name", async (t) => { | ||
// setup | ||
const moduleInfo = new ModuleInfo("myName"); | ||
|
||
// action | ||
moduleInfo.addDependency("newName", false); | ||
moduleInfo.name = "newName"; | ||
|
||
moduleInfo.addSubModule("newName2"); | ||
moduleInfo.name = "newName2"; | ||
|
||
// expectation | ||
t.deepEqual(moduleInfo.subModules, [], "submodule is empty"); | ||
t.deepEqual(moduleInfo.dependencies, [], "dependencies is empty"); | ||
t.is(moduleInfo.name, "newName2", "name was set"); | ||
}); | ||
|
||
test("ModuleInfo: toString", async (t) => { | ||
// setup | ||
const moduleInfo = new ModuleInfo("myName"); | ||
|
||
// action | ||
moduleInfo.addDependency("dep1", false); | ||
moduleInfo.addDependency("dep2", false); | ||
moduleInfo.addSubModule("sub1"); | ||
moduleInfo.addSubModule("sub2"); | ||
const stringContent = moduleInfo.toString(); | ||
|
||
// expectation | ||
t.is(stringContent, "ModuleInfo(myName, dependencies=dep1,dep2, includes=sub1,sub2)", "string value is correct"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const test = require("ava"); | ||
const path = require("path"); | ||
|
||
const parentLogger = require("@ui5/logger").getGroupLogger("mygroup"); | ||
|
||
const LibraryBuilder = require("../../../../lib/types/library/LibraryBuilder"); | ||
|
||
function clone(o) { | ||
return JSON.parse(JSON.stringify(o)); | ||
} | ||
|
||
test("Instantiation", (t) => { | ||
const project = clone(libraryETree); | ||
const appBuilder = new LibraryBuilder({parentLogger, project}); | ||
t.truthy(appBuilder); | ||
t.deepEqual(appBuilder.taskExecutionOrder, [ | ||
"escapeNonAsciiCharacters", | ||
"replaceCopyright", | ||
"replaceVersion", | ||
"generateJsdoc", | ||
"executeJsdocSdkTransformation", | ||
"generateLibraryManifest", | ||
"generateManifestBundle", | ||
"generateLibraryPreload", | ||
"buildThemes", | ||
"createDebugFiles", | ||
"uglify", | ||
"generateResourcesJson" | ||
], "LibraryBuilder is instantiated with standard tasks"); | ||
}); | ||
|
||
const libraryEPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.e"); | ||
const libraryETree = { | ||
id: "library.e.id", | ||
version: "1.0.0", | ||
path: libraryEPath, | ||
dependencies: [], | ||
_level: 0, | ||
_isRoot: true, | ||
specVersion: "2.0", | ||
type: "library", | ||
metadata: { | ||
name: "library.e", | ||
copyright: "some fancy copyright.", | ||
namespace: "library.e" | ||
}, | ||
resources: { | ||
configuration: { | ||
paths: { | ||
src: "src", | ||
test: "test" | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const test = require("ava"); | ||
|
||
const ThemeLibraryBuilder = require("../../../../lib/types/themeLibrary/ThemeLibraryBuilder"); | ||
|
||
test("tasks", async (t) => { | ||
const themeLibraryBuilder = new ThemeLibraryBuilder({ | ||
resourceCollections: { | ||
workspace: { | ||
byGlob: async () => { | ||
return []; | ||
} | ||
} | ||
}, | ||
buildContext: { | ||
isRootProject: () => { | ||
return true; | ||
} | ||
}, | ||
project: { | ||
metadata: { | ||
name: "name", | ||
copyright: "copyright" | ||
}, | ||
type: "type" | ||
}, | ||
parentLogger: { | ||
createSubLogger: () => { | ||
return { | ||
createTaskLogger: () => { | ||
return { | ||
addWork: () => undefined, | ||
startWork: () => undefined, | ||
completeWork: () => undefined | ||
}; | ||
} | ||
}; | ||
} | ||
}, | ||
taskUtil: { | ||
isRootProject: () => { | ||
return true; | ||
} | ||
} | ||
}); | ||
|
||
const taskNames = Object.keys(themeLibraryBuilder.tasks); | ||
t.deepEqual(taskNames, [ | ||
"replaceCopyright", | ||
"replaceVersion", | ||
"buildThemes", | ||
"generateResourcesJson", | ||
], "Expected tasks have been added"); | ||
|
||
await themeLibraryBuilder.build(taskNames); | ||
}); |