Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Sep 8, 2022
1 parent 73be7aa commit adfe5f4
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions packages/docusaurus-logger/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ describe('report', () => {
).toThrowErrorMatchingInlineSnapshot(
`"Unexpected "reportingSeverity" value: foo."`,
);
expect(consoleLog).toBeCalledTimes(1);
expect(consoleLog).toBeCalledWith(
expect(consoleLog).toHaveBeenCalledTimes(1);
expect(consoleLog).toHaveBeenCalledWith(
expect.stringMatching(/.*\[INFO\].* hey/),
);
expect(consoleWarn).toBeCalledTimes(1);
expect(consoleWarn).toBeCalledWith(
expect(consoleWarn).toHaveBeenCalledTimes(1);
expect(consoleWarn).toHaveBeenCalledWith(
expect.stringMatching(/.*\[WARNING\].* hey/),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ describe('transformImage plugin', () => {
const errorMock = jest.spyOn(console, 'warn').mockImplementation(() => {});
const result = await processFixture('invalid-img', {staticDirs});
expect(result).toMatchSnapshot();
expect(errorMock).toBeCalledTimes(1);
expect(errorMock).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe.each(['atom', 'rss', 'json'])('%s', (feedType) => {
} as PluginOptions,
);

expect(fsMock).toBeCalledTimes(0);
expect(fsMock).toHaveBeenCalledTimes(0);
fsMock.mockClear();
});

Expand Down
Binary file modified packages/docusaurus-plugin-content-docs/src/__tests__/cli.test.ts
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ describe('loadSidebars', () => {
} as VersionMetadata,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`""foo" is not allowed"`);
expect(consoleWarnMock).toBeCalledWith(
expect(consoleWarnMock).toHaveBeenCalledWith(
expect.stringMatching(
/.*\[WARNING\].* There are more than one category metadata files for .*foo.*: foo\/_category_.json, foo\/_category_.yml. The behavior is undetermined./,
),
);
expect(consoleErrorMock).toBeCalledWith(
expect(consoleErrorMock).toHaveBeenCalledWith(
expect.stringMatching(
/.*\[ERROR\].* The docs sidebar category metadata file .*foo\/_category_.json.* looks invalid!/,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('normalizePluginOptions', () => {
options,
),
).toEqual({foo: 'a', id: 'default'});
expect(consoleMock).toBeCalledWith(
expect(consoleMock).toHaveBeenCalledWith(
expect.stringMatching(/"foo" deprecated/),
);
});
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('normalizeThemeConfig', () => {
themeConfig,
),
).toEqual(themeConfig);
expect(consoleMock).toBeCalledWith(
expect(consoleMock).toHaveBeenCalledWith(
expect.stringMatching(/"foo" deprecated/),
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-utils/src/__tests__/emitUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ describe('generate', () => {

it('works with existing cache', async () => {
await generate(__dirname, 'foo', 'bar');
expect(writeMock).toBeCalledTimes(1);
expect(writeMock).toHaveBeenCalledTimes(1);
});

it('works with existing file but no cache', async () => {
existsMock.mockImplementationOnce(() => true);
// @ts-expect-error: seems the typedef doesn't understand overload
readMock.mockImplementationOnce(() => Promise.resolve('bar'));
await generate(__dirname, 'baz', 'bar');
expect(writeMock).toBeCalledTimes(1);
expect(writeMock).toHaveBeenCalledTimes(1);
});

it('works when force skipping cache', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-utils/src/__tests__/gitUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ describe('getFileCommitDate', () => {
age: 'newest',
includeAuthor: true,
}),
).toThrowError(FileNotTrackedError);
).toThrow(FileNotTrackedError);
});
it('throws when file not found', async () => {
expect(() =>
getFileCommitDate(path.join(repoDir, 'nonexistent.txt'), {
age: 'newest',
includeAuthor: true,
}),
).toThrowError(
).toThrow(
/Failed to retrieve git history for ".*nonexistent.txt" because the file does not exist./,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('normalizeLocation', () => {
search: '',
hash: '#features',
});
expect(replaceMock).toBeCalledTimes(1);
expect(replaceMock).toHaveBeenCalledTimes(1);

expect(
normalizeLocation({
Expand Down
8 changes: 4 additions & 4 deletions packages/docusaurus/src/server/__tests__/brokenLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('handleBrokenLinks', () => {

it('do not report anything for correct paths', async () => {
const consoleMock = jest
.spyOn(console, 'error')
.spyOn(console, 'warn')
.mockImplementation(() => {});
const allCollectedCorrectLinks = {
'/docs/good doc with space': [
Expand Down Expand Up @@ -136,12 +136,12 @@ describe('handleBrokenLinks', () => {
};
await handleBrokenLinks({
allCollectedLinks: allCollectedCorrectLinks,
onBrokenLinks: 'error',
onBrokenLinks: 'warn',
routes,
baseUrl: '/',
outDir,
});
expect(consoleMock).toBeCalledTimes(0);
expect(consoleMock).toHaveBeenCalledTimes(0);
});

it('reports all broken links', async () => {
Expand All @@ -167,7 +167,7 @@ describe('handleBrokenLinks', () => {
baseUrl: '/',
outDir,
});
expect(lodashMock).toBeCalledTimes(0);
expect(lodashMock).toHaveBeenCalledTimes(0);
lodashMock.mockRestore();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe('normalizeConfig', () => {
normalizeConfig({
plugins,
} as Config);
}).not.toThrowError();
}).not.toThrow();
});

it.each([
Expand Down Expand Up @@ -223,7 +223,7 @@ describe('normalizeConfig', () => {
normalizeConfig({
themes,
} as Config);
}).not.toThrowError();
}).not.toThrow();
});

it('throws error if themes is not array', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/server/__tests__/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('handleDuplicateRoutes', () => {
}).toThrowErrorMatchingSnapshot();
const consoleMock = jest.spyOn(console, 'log').mockImplementation(() => {});
handleDuplicateRoutes(routes, 'ignore');
expect(consoleMock).toBeCalledTimes(0);
expect(consoleMock).toHaveBeenCalledTimes(0);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('writeCodeTranslations', () => {
key2: {message: 'key2 message'},
key3: {message: 'key3 message'},
});
expect(consoleInfoMock).toBeCalledWith(
expect(consoleInfoMock).toHaveBeenCalledWith(
expect.stringMatching(/3.* translations will be written/),
);
});
Expand All @@ -100,7 +100,7 @@ describe('writeCodeTranslations', () => {
key2: {message: 'PREFIX key2 message'},
key3: {message: 'PREFIX key3 message'},
});
expect(consoleInfoMock).toBeCalledWith(
expect(consoleInfoMock).toHaveBeenCalledWith(
expect.stringMatching(/3.* translations will be written/),
);
});
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('writeCodeTranslations', () => {
key3: {message: 'key3 message'},
key4: {message: 'key4 message new'},
});
expect(consoleInfoMock).toBeCalledWith(
expect(consoleInfoMock).toHaveBeenCalledWith(
expect.stringMatching(/4.* translations will be written/),
);
});
Expand All @@ -154,7 +154,7 @@ describe('writeCodeTranslations', () => {
key1: {message: 'key1 message'},
key2: {message: 'PREFIX key2 message new'},
});
expect(consoleInfoMock).toBeCalledWith(
expect(consoleInfoMock).toHaveBeenCalledWith(
expect.stringMatching(/2.* translations will be written/),
);
});
Expand All @@ -179,7 +179,7 @@ describe('writeCodeTranslations', () => {
key1: {message: 'key1 message new'},
key2: {message: 'key2 message new'},
});
expect(consoleInfoMock).toBeCalledWith(
expect(consoleInfoMock).toHaveBeenCalledWith(
expect.stringMatching(/2.* translations will be written/),
);
});
Expand All @@ -205,7 +205,7 @@ describe('writeCodeTranslations', () => {
key1: {message: 'PREFIX key1 message new'},
key2: {message: 'PREFIX key2 message new'},
});
expect(consoleInfoMock).toBeCalledWith(
expect(consoleInfoMock).toHaveBeenCalledWith(
expect.stringMatching(/2.* translations will be written/),
);
});
Expand All @@ -232,7 +232,7 @@ describe('writeCodeTranslations', () => {
key2: {message: 'key2 message', description: 'key2 desc new'},
key3: {message: 'key3 message', description: 'key3 desc new'},
});
expect(consoleInfoMock).toBeCalledWith(
expect(consoleInfoMock).toHaveBeenCalledWith(
expect.stringMatching(/3.* translations will be written/),
);
});
Expand All @@ -242,10 +242,10 @@ describe('writeCodeTranslations', () => {

await writeCodeTranslations({localizationDir}, {}, {});

await expect(readFile()).rejects.toThrowError(
await expect(readFile()).rejects.toThrow(
/ENOENT: no such file or directory, open /,
);
expect(consoleInfoMock).toBeCalledTimes(0);
expect(consoleInfoMock).toHaveBeenCalledTimes(0);
});

it('throws for invalid content', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const default => {
extractSourceCodeFileTranslations(sourceCodeFilePath, TestBabelOptions),
).rejects.toThrow();

expect(errorMock).toBeCalledWith(
expect(errorMock).toHaveBeenCalledWith(
expect.stringMatching(
/Error while attempting to extract Docusaurus translations from source code file at/,
),
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/webpack/__tests__/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ describe('base webpack config', () => {
.mockImplementation(() => fileLoaderUtils);

await createBaseConfig(props, false, false);
expect(mockSvg).toBeCalled();
expect(mockSvg).toHaveBeenCalled();
});
});
4 changes: 2 additions & 2 deletions packages/docusaurus/src/webpack/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,13 @@ describe('getHttpsConfig', () => {
process.env.HTTPS = 'true';
process.env.SSL_CRT_FILE = path.join(__dirname, '__fixtures__/host.crt');
process.env.SSL_KEY_FILE = path.join(__dirname, '__fixtures__/invalid.key');
await expect(getHttpsConfig()).rejects.toThrowError();
await expect(getHttpsConfig()).rejects.toThrow();
});

it('throws for invalid cert', async () => {
process.env.HTTPS = 'true';
process.env.SSL_CRT_FILE = path.join(__dirname, '__fixtures__/invalid.crt');
process.env.SSL_KEY_FILE = path.join(__dirname, '__fixtures__/host.key');
await expect(getHttpsConfig()).rejects.toThrowError();
await expect(getHttpsConfig()).rejects.toThrow();
});
});

0 comments on commit adfe5f4

Please sign in to comment.