Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING] Make namespace mandatory for application and library projects #430

Merged
merged 9 commits into from
Mar 20, 2020
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) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this testing exactly? The caching mechanism inside getDotLibrary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if I remove the caching here:

if (this._pDotLibrary) {
return this._pDotLibrary;
}

The test will still be successful because it doesn't actually test whether something got cached (e.g. no second glob call).


Also, there is already tests for this. It just seem to be incorrect since its missing a second call:

test.serial("getDotLibrary: result is cached", async (t) => {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

...

So we gonna fix the existing test instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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