Skip to content

Commit

Permalink
review-fix:関数をそのままimportする
Browse files Browse the repository at this point in the history
  • Loading branch information
marumoto-goq committed May 7, 2024
1 parent 73a798d commit 383a625
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/test/utils/checkLength.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { expect } from '@jest/globals';
import { goqZipCode } from '../goqZipCode';
import { checkLength } from '.';

describe('郵便番号が期待する桁数かチェック', () => {
test('完全一致検索で入力データが7文字ならtrueを返す', () => {
expect(goqZipCode.checkLength(true, 7)).toBe(true);
expect(checkLength(true, 7)).toBe(true);
});

test('完全一致検索で入力データが7文字以外ならfalseを返す', () => {
expect(goqZipCode.checkLength(true, 8)).toBe(false);
expect(checkLength(true, 8)).toBe(false);
});

test('部分一致検索で入力データが2文字以上ならtrueを返す', () => {
expect(goqZipCode.checkLength(false, 2)).toBe(true);
expect(checkLength(false, 2)).toBe(true);
});

test('部分一致検索で入力データが1文字以下の場合はfalseを返す', () => {
expect(goqZipCode.checkLength(false, 1)).toBe(false);
expect(checkLength(false, 1)).toBe(false);
});
});
4 changes: 2 additions & 2 deletions src/test/utils/convertHyphenatedZipCode.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from '@jest/globals';
import { goqZipCode } from '../goqZipCode';
import { convertHyphenatedZipCode } from './';

test('郵便番号にハイフンを追加', () => {
expect(goqZipCode.convertHyphenatedZipCode('7340001')).toBe('734-0001');
expect(convertHyphenatedZipCode('7340001')).toBe('734-0001');
});
10 changes: 5 additions & 5 deletions src/test/utils/convertZipCode.test.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { expect } from '@jest/globals';
import { goqZipCode } from '../goqZipCode';
import { convertZipCode } from './';

describe('convertZipCodeの動作をテスト', () => {
const expectedZipCodeExcludingHyphen = '7320021';

test('全角の郵便番号を半角に変換', () => {
expect(goqZipCode.convertZipCode('7320021')).toBe(
expect(convertZipCode('7320021')).toBe(
expectedZipCodeExcludingHyphen
);
});

test('全角の郵便番号を半角に変換して、ハイフンを削除', () => {
expect(goqZipCode.convertZipCode('732ー0021')).toBe(
expect(convertZipCode('732ー0021')).toBe(
expectedZipCodeExcludingHyphen
);
});

test('半角のハイフンを削除', () => {
expect(goqZipCode.convertZipCode('732-0021')).toBe(
expect(convertZipCode('732-0021')).toBe(
expectedZipCodeExcludingHyphen
);
});

test('半角と全角の郵便番号を半角に変換', () => {
expect(goqZipCode.convertZipCode('7320021')).toBe(
expect(convertZipCode('7320021')).toBe(
expectedZipCodeExcludingHyphen
);
});
Expand Down

0 comments on commit 383a625

Please sign in to comment.