Skip to content

Commit

Permalink
refactor(tests): rename test cases and snapshots for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuunen committed Dec 7, 2024
1 parent 57a3c4f commit dcb1eff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/__snapshots__/check.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`check A folder fails with low max size 1`] = `"failed at validating at least one rule in one folder : package-json-main-file-size-49ko-should-be-less-or-equal-to-max-size-allowed-2ko"`;
exports[`check A repo-checker folder fails with low max size 1`] = `"failed at validating at least one rule in one folder : package-json-main-file-size-49ko-should-be-less-or-equal-to-max-size-allowed-2ko"`;

exports[`check B folder succeed 1`] = `
exports[`check B repo-checker folder succeed 1`] = `
{
"failed": [],
"passed": [
Expand Down Expand Up @@ -178,7 +178,7 @@ exports[`check B folder succeed 1`] = `
}
`;

exports[`check C data/tsProject 1`] = `
exports[`check C ts-project folder 1`] = `
{
"failed": [
"has-a-editorconfig-file",
Expand Down Expand Up @@ -270,9 +270,9 @@ exports[`check C data/tsProject 1`] = `
}
`;

exports[`check D data folders and throw 1`] = `"failed at validating at least one rule in one folder : has-a-editorconfig-file, has-a-gitignore-file, has-a-license-file, has-a-nvmrc-file, package-json-do..."`;
exports[`check D mocks-projects folders and throw 1`] = `"failed at validating at least one rule in one folder : has-a-editorconfig-file, has-a-gitignore-file, has-a-license-file, has-a-nvmrc-file, package-json-do..."`;

exports[`check E data folders and not throw 1`] = `
exports[`check E mocks-projects folders and not throw 1`] = `
{
"failed": [
"has-a-editorconfig-file",
Expand Down
10 changes: 5 additions & 5 deletions src/check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ import { check } from './check'
import { ProjectData, repoCheckerPath } from './constants'
import { mocksProjectsFolder, tsProjectFolder } from './mock'

it('check A folder fails with low max size', async () => {
it('check A repo-checker folder fails with low max size', async () => {
const data = new ProjectData({ isPublishedPackage: true, isQuiet: true, maxSizeKo: 2 })
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const message = await check({ data, folderPath: repoCheckerPath }).catch((error: unknown) => (error as Error).message)
expect(message).toMatchSnapshot()
})

it('check B folder succeed', async () => {
it('check B repo-checker folder succeed', async () => {
const data = new ProjectData({ isModule: true, isPublishedPackage: true, isQuiet: true, maxSizeKo: 120 })
const indicators = await check({ data, folderPath: repoCheckerPath })
expect(indicators).toMatchSnapshot()
})

it('check C data/tsProject', async () => {
it('check C ts-project folder', async () => {
const data = new ProjectData({ isQuiet: true })
const indicators = await check({ canThrow: false, data, folderPath: tsProjectFolder })
expect(indicators).toMatchSnapshot()
})

it('check D data folders and throw', async () => {
it('check D mocks-projects folders and throw', async () => {
const data = new ProjectData({ isQuiet: true })
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const message = await check({ canFailStop: true, data, folderPath: mocksProjectsFolder }).catch((error: unknown) => (error as Error).message)
expect(message).toMatchSnapshot()
})

it('check E data folders and not throw', async () => {
it('check E mocks-projects folders and not throw', async () => {
const data = new ProjectData({ isQuiet: true })
const indicators = await check({ canFailStop: true, canThrow: false, data, folderPath: mocksProjectsFolder })
expect(indicators).toMatchSnapshot()
Expand Down

0 comments on commit dcb1eff

Please sign in to comment.