diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/.library b/test/expected/build/library.h/dest-resources-json/resources/library/h/.library index 5bdab13ab..9084728e8 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/.library +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/.library @@ -6,7 +6,7 @@ Some fancy copyright 1.0.0 - Library D + Library H diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json index 2e67ab58d..2b6c457ad 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json @@ -12,8 +12,8 @@ "applicationVersion": { "version": "1.0.0" }, - "title": "Library D", - "description": "Library D", + "title": "Library H", + "description": "Library H", "resources": "resources.json", "offline": true }, diff --git a/test/expected/build/library.h/dest/resources/library/h/.library b/test/expected/build/library.h/dest/resources/library/h/.library index 5bdab13ab..9084728e8 100644 --- a/test/expected/build/library.h/dest/resources/library/h/.library +++ b/test/expected/build/library.h/dest/resources/library/h/.library @@ -6,7 +6,7 @@ Some fancy copyright 1.0.0 - Library D + Library H diff --git a/test/expected/build/library.h/dest/resources/library/h/manifest.json b/test/expected/build/library.h/dest/resources/library/h/manifest.json index 2e67ab58d..2b6c457ad 100644 --- a/test/expected/build/library.h/dest/resources/library/h/manifest.json +++ b/test/expected/build/library.h/dest/resources/library/h/manifest.json @@ -12,8 +12,8 @@ "applicationVersion": { "version": "1.0.0" }, - "title": "Library D", - "description": "Library D", + "title": "Library H", + "description": "Library H", "resources": "resources.json", "offline": true }, diff --git a/test/fixtures/library.h/main/src/library/h/.library b/test/fixtures/library.h/main/src/library/h/.library index 797c61cc8..38501ff40 100644 --- a/test/fixtures/library.h/main/src/library/h/.library +++ b/test/fixtures/library.h/main/src/library/h/.library @@ -6,7 +6,7 @@ Some fancy copyright ${version} - Library D + Library H diff --git a/test/lib/lbt/resources/ModuleInfo.js b/test/lib/lbt/resources/ModuleInfo.js new file mode 100644 index 000000000..9ecc16569 --- /dev/null +++ b/test/lib/lbt/resources/ModuleInfo.js @@ -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"); +}); diff --git a/test/lib/types/library/LibraryBuilder.js b/test/lib/types/library/LibraryBuilder.js new file mode 100644 index 000000000..e039a18d4 --- /dev/null +++ b/test/lib/types/library/LibraryBuilder.js @@ -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" + } + } + } +}; diff --git a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js new file mode 100644 index 000000000..cf358458d --- /dev/null +++ b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js @@ -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); +});