Skip to content

Commit

Permalink
#38 extractCatNameById のテスト追加とディレクトリの整理
Browse files Browse the repository at this point in the history
  • Loading branch information
keitakn committed Jul 4, 2023
1 parent 1320590 commit 3fd80aa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/features/__tests__/cat/extractCatNameById.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { extractCatNameById, type CatId } from '@/features';
import { ExhaustiveError } from '@/utils';
import type { CatName } from '../../cat';

describe('src/features/cat.ts extractCatNameById TestCases', () => {
type TestTable = {
catId: CatId;
expected: CatName;
};

it.each`
catId | expected
${'moko'} | ${'もこ'}
`(
'should return catName. catId: $catId',
({ catId, expected }: TestTable) => {
expect(extractCatNameById(catId)).toStrictEqual(expected);
}
);

it.each`
catId
${'cat'}
${'unknown'}
`('should ExhaustiveError Throw. catId: $catId', ({ catId }: TestTable) => {
expect(() => extractCatNameById(catId)).toThrow(ExhaustiveError);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-magic-numbers */
import { isCatId, type CatId } from '@/features';

describe('src/features/cat.ts isCatId TestCases', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/features/cat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type CatId = (typeof catIds)[number];

const catNames = ['もこ'] as const;

type CatName = (typeof catNames)[number];
export type CatName = (typeof catNames)[number];

export type FetchCatMessageDto = {
catId: CatId;
Expand Down

0 comments on commit 3fd80aa

Please sign in to comment.