chore: enable eslint-plugin-jest (#6375)

This commit is contained in:
Joshua Chen 2022-01-16 15:53:23 +08:00 committed by GitHub
parent 3e5944ef1f
commit 52db7320a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 194 additions and 193 deletions

View file

@ -23,102 +23,104 @@ describe('getDataFilePath', () => {
const contentPathNestedYml = path.join(fixturesDir, 'contentPathNestedYml');
test('getDataFilePath returns localized Yml path in priority', async () => {
expect(
await getDataFilePath({
await expect(
getDataFilePath({
filePath: 'authors.yml',
contentPaths: {
contentPathLocalized: contentPathYml1,
contentPath: contentPathYml2,
},
}),
).toEqual(path.join(contentPathYml1, 'authors.yml'));
expect(
await getDataFilePath({
).resolves.toEqual(path.join(contentPathYml1, 'authors.yml'));
await expect(
getDataFilePath({
filePath: 'authors.yml',
contentPaths: {
contentPathLocalized: contentPathYml2,
contentPath: contentPathYml1,
},
}),
).toEqual(path.join(contentPathYml2, 'authors.yml'));
).resolves.toEqual(path.join(contentPathYml2, 'authors.yml'));
});
test('getDataFilePath returns localized Json path in priority', async () => {
expect(
await getDataFilePath({
await expect(
getDataFilePath({
filePath: 'authors.json',
contentPaths: {
contentPathLocalized: contentPathJson1,
contentPath: contentPathJson2,
},
}),
).toEqual(path.join(contentPathJson1, 'authors.json'));
expect(
await getDataFilePath({
).resolves.toEqual(path.join(contentPathJson1, 'authors.json'));
await expect(
getDataFilePath({
filePath: 'authors.json',
contentPaths: {
contentPathLocalized: contentPathJson2,
contentPath: contentPathJson1,
},
}),
).toEqual(path.join(contentPathJson2, 'authors.json'));
).resolves.toEqual(path.join(contentPathJson2, 'authors.json'));
});
test('getDataFilePath returns unlocalized Yml path as fallback', async () => {
expect(
await getDataFilePath({
await expect(
getDataFilePath({
filePath: 'authors.yml',
contentPaths: {
contentPathLocalized: contentPathEmpty,
contentPath: contentPathYml2,
},
}),
).toEqual(path.join(contentPathYml2, 'authors.yml'));
).resolves.toEqual(path.join(contentPathYml2, 'authors.yml'));
});
test('getDataFilePath returns unlocalized Json path as fallback', async () => {
expect(
await getDataFilePath({
await expect(
getDataFilePath({
filePath: 'authors.json',
contentPaths: {
contentPathLocalized: contentPathEmpty,
contentPath: contentPathJson1,
},
}),
).toEqual(path.join(contentPathJson1, 'authors.json'));
).resolves.toEqual(path.join(contentPathJson1, 'authors.json'));
});
test('getDataFilePath can return undefined (file not found)', async () => {
expect(
await getDataFilePath({
await expect(
getDataFilePath({
filePath: 'authors.json',
contentPaths: {
contentPathLocalized: contentPathEmpty,
contentPath: contentPathYml1,
},
}),
).toBeUndefined();
expect(
await getDataFilePath({
).resolves.toBeUndefined();
await expect(
getDataFilePath({
filePath: 'authors.yml',
contentPaths: {
contentPathLocalized: contentPathEmpty,
contentPath: contentPathJson1,
},
}),
).toBeUndefined();
).resolves.toBeUndefined();
});
test('getDataFilePath can return nested path', async () => {
expect(
await getDataFilePath({
await expect(
getDataFilePath({
filePath: 'sub/folder/authors.yml',
contentPaths: {
contentPathLocalized: contentPathEmpty,
contentPath: contentPathNestedYml,
},
}),
).toEqual(path.join(contentPathNestedYml, 'sub/folder/authors.yml'));
).resolves.toEqual(
path.join(contentPathNestedYml, 'sub/folder/authors.yml'),
);
});
});

View file

@ -321,11 +321,11 @@ describe('mapAsyncSequential', () => {
const timeTotal = timeAfter - timeBefore;
const totalTimeouts = sum(Object.values(itemToTimeout));
expect(timeTotal > totalTimeouts);
expect(timeTotal).toBeGreaterThanOrEqual(totalTimeouts);
expect(itemMapStartsAt['1'] > 0);
expect(itemMapStartsAt['2'] > itemMapEndsAt['1']);
expect(itemMapStartsAt['3'] > itemMapEndsAt['2']);
expect(itemMapStartsAt['1']).toBeGreaterThanOrEqual(0);
expect(itemMapStartsAt['2']).toBeGreaterThanOrEqual(itemMapEndsAt['1']);
expect(itemMapStartsAt['3']).toBeGreaterThanOrEqual(itemMapEndsAt['2']);
});
});
@ -353,8 +353,8 @@ describe('findAsyncSequential', () => {
expect(findFn).toHaveBeenNthCalledWith(2, '2');
const timeTotal = timeAfter - timeBefore;
expect(timeTotal > 100);
expect(timeTotal < 150);
expect(timeTotal).toBeGreaterThanOrEqual(100);
expect(timeTotal).toBeLessThan(150);
});
});

View file

@ -802,7 +802,7 @@ describe('parseMarkdownString', () => {
`);
});
test('should delete only first heading', () => {
test('should delete only first heading 2', () => {
expect(
parseMarkdownString(dedent`
# test

View file

@ -46,7 +46,7 @@ describe('normalizeFrontMatterTag', () => {
expect(normalizeFrontMatterTag(tagsPath, input)).toEqual(expectedOutput);
});
test('should normalize complex string tag', () => {
test('should normalize complex string tag with object tag', () => {
const tagsPath = '/all/tags';
const input: Input = {
label: 'tag complex Label',