mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-16 10:37:20 +02:00
refactor(pwa): simplify registerSW code, fix ESLint errors (#7579)
This commit is contained in:
parent
bada5c11cc
commit
7869e74fd7
14 changed files with 204 additions and 247 deletions
|
@ -22,7 +22,7 @@ describe('getFileLastUpdate', () => {
|
|||
const lastUpdateData = await getFileLastUpdate(existingFilePath);
|
||||
expect(lastUpdateData).not.toBeNull();
|
||||
|
||||
const {author, timestamp} = lastUpdateData;
|
||||
const {author, timestamp} = lastUpdateData!;
|
||||
expect(author).not.toBeNull();
|
||||
expect(typeof author).toBe('string');
|
||||
|
||||
|
@ -38,7 +38,7 @@ describe('getFileLastUpdate', () => {
|
|||
const lastUpdateData = await getFileLastUpdate(filePathWithSpace);
|
||||
expect(lastUpdateData).not.toBeNull();
|
||||
|
||||
const {author, timestamp} = lastUpdateData;
|
||||
const {author, timestamp} = lastUpdateData!;
|
||||
expect(author).not.toBeNull();
|
||||
expect(typeof author).toBe('string');
|
||||
|
||||
|
@ -61,8 +61,6 @@ describe('getFileLastUpdate', () => {
|
|||
expect(consoleMock).toHaveBeenLastCalledWith(
|
||||
expect.stringMatching(/because the file does not exist./),
|
||||
);
|
||||
await expect(getFileLastUpdate(null)).resolves.toBeNull();
|
||||
await expect(getFileLastUpdate(undefined)).resolves.toBeNull();
|
||||
consoleMock.mockRestore();
|
||||
});
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ let showedGitRequirementError = false;
|
|||
let showedFileNotTrackedError = false;
|
||||
|
||||
export async function getFileLastUpdate(
|
||||
filePath?: string,
|
||||
filePath: string,
|
||||
): Promise<{timestamp: number; author: string} | null> {
|
||||
if (!filePath) {
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue