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
Refactor lib/__tests__/standalone-cache.test.js
#5311
Conversation
- Reduce redundant callbacks via `async/await` syntax. (#4881) - Use `fs.existsSync()` instead of `fs.access()`. See <https://nodejs.org/api/fs.html#fs_fs_existssync_path> - Fix the disabled test. (#5309) - Inline redundant local variables. - Make expectations using `typeof` more accurate.
fs.access(filePath, fsConstants.F_OK).then( | ||
() => true, | ||
() => false, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] I think it simple and enough to use fs.existsSync()
for tests.
}); | ||
// Ensure cache file contains only linted css file | ||
expect(typeof cache.getKey(validFile)).toBe('object'); | ||
expect(cache.getKey(validFile)).toBeTruthy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] I've added the expectation .toBeTruthy()
because of typeof null === 'object'
. But it may be a bit ugly and is not DRY. 🤔
|
||
it("cache doesn't do anything if string is passed", async () => { | ||
// Ensure no cache file | ||
await removeFile(expectedCacheFilePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] This addition of removeFile()
fixes #5309.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
async/await
syntax. (Fix tests that use callbacks #4881)fs.existsSync()
instead offs.access()
.See https://nodejs.org/api/fs.html#fs_fs_existssync_path
typeof
more accurate.Fix #5309
A part of #4881
This PR's base branch is
v14
.