From 7773b4e8c6154330a16e6c7a5aff79ecc5579c63 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 17 Mar 2020 13:38:27 +0100 Subject: [PATCH] add test for LibraryFormatter#getLibraryJsPath and getDotLibrary --- test/lib/types/library/LibraryFormatter.js | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/lib/types/library/LibraryFormatter.js b/test/lib/types/library/LibraryFormatter.js index cb075aa6c..3389c6e50 100644 --- a/test/lib/types/library/LibraryFormatter.js +++ b/test/lib/types/library/LibraryFormatter.js @@ -284,6 +284,21 @@ test("getDotLibrary: reads correctly", async (t) => { t.deepEqual(fsPath, expectedPath, ".library fsPath is correct"); }); +test("getDotLibrary: reads correctly call again", async (t) => { + const myProject = clone(libraryETree); + myProject.resources.pathMappings = { + "/resources/": myProject.resources.configuration.paths.src + }; + + const libraryFormatter = new LibraryFormatter({project: myProject}); + + const {content} = await libraryFormatter.getDotLibrary(); + t.deepEqual(content.library.name, "library.e", ".library content has been read"); + + const {content: contentSecondCall} = await libraryFormatter.getDotLibrary(); + t.deepEqual(contentSecondCall.library.name, "library.e", ".library content has been read second time"); +}); + test.serial("getDotLibrary: multiple dot library files", async (t) => { const myProject = clone(libraryETree); myProject.resources.pathMappings = { @@ -365,6 +380,25 @@ test("getLibraryJsPath: reads correctly", async (t) => { t.deepEqual(fsPath, expectedPath, ".library fsPath is correct"); }); +test("getLibraryJsPath: reads correctly call again", async (t) => { + const myProject = clone(libraryETree); + myProject.resources.pathMappings = { + "/resources/": myProject.resources.configuration.paths.src + }; + + const libraryFormatter = new LibraryFormatter({project: myProject}); + + const fsPath = await libraryFormatter.getLibraryJsPath(); + const expectedPath = path.join(myProject.path, + myProject.resources.configuration.paths.src, "library", "e", "library.js"); + t.deepEqual(fsPath, expectedPath, ".library fsPath is correct"); + + const fsPathSecondCall = await libraryFormatter.getLibraryJsPath(); + const expectedPathSecondCall = path.join(myProject.path, + myProject.resources.configuration.paths.src, "library", "e", "library.js"); + t.deepEqual(fsPathSecondCall, expectedPathSecondCall, ".library fsPath is correct"); +}); + test.serial("getLibraryJsPath: multiple dot library files", async (t) => { const myProject = clone(libraryETree); myProject.resources.pathMappings = {