Skip to content

Commit

Permalink
Merge pull request #462 from munierujp/refactoring
Browse files Browse the repository at this point in the history
`getNowYMD` のテストを改善
  • Loading branch information
NEKOYASAN authored Jan 6, 2024
2 parents 8bf0e59 + 5fc9343 commit 7eb25ee
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test-unit/lib/displayHelper.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { getNowYMD } from '~/lib/displayHelper';

describe('getNowYMD', () => {
test('returns the formatted date in Japanese by customization', () => {
const mockDate = new Date('2022-01-05T12:34:56');
const result = getNowYMD(mockDate, 'ja');
expect(result).toBe('2022年01月05日12時34分');
describe('returns the formatted date in Japanese by customization', () => {
test.each([
['2022-01-01T00:00:00', '2022年01月01日00時00分'],
['2022-01-01T01:01:01', '2022年01月01日01時01分'],
['2022-12-31T23:59:59', '2022年12月31日23時59分']
])('date=%p', (date, expected) => {
const mockDate = new Date(date);
const result = getNowYMD(mockDate, 'ja');
expect(result).toBe(expected);
})
});

test('returns the formatted date in English when locale is set to "en"', () => {
Expand Down

0 comments on commit 7eb25ee

Please sign in to comment.