Skip to content

Commit

Permalink
add test for LibraryFormatter#getLibraryJsPath and getDotLibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasso85 committed Mar 17, 2020
1 parent 7b8fc99 commit 7773b4e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/lib/types/library/LibraryFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 7773b4e

Please sign in to comment.