Skip to content

Commit

Permalink
test: add test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Feb 27, 2023
1 parent 3a82af9 commit d660ac4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ console.log(formatter('YYYY年MM月DD日', new Date(2019, 3, 7)))
//=> 2019年04月07日
console.log(formatter('YYYY年MM月DD日 16:30:29', new Date(2019, 3, 7, 16, 30, 29)))
//=> 2019年04月07日 16:30:29
console.log(formatter('YYYY年MM月DD日 HH:mm-ss', new Date(2019, 3, 7, 16, 30, 29)))
//=> 2019年04月07日 16:30-29
console.log(formatter('YYYY/MM/DD HH:mm:ss', new Date(2019, 3, 7, 16, 30, 29)))
//=> 2019年04月07日 16:30-29
console.log(formatter('YYYY/MM/DD HH:mm:ss', new Date(2019, 3, 7, 16, 30, 29)))
//=> 2019/04/07 16:30:29


console.log(formatter('YYYY'));
Expand Down
2 changes: 2 additions & 0 deletions test/formatter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ test('should return the default formatter', () => {
test('should return a fixed time format:', () => {
expect(formatter('YYYY年MM月DD日', new Date(2019, 3, 7))).toEqual('2019年04月07日');
expect(formatter('YYYY年MM月DD日 16:30:29', new Date(2019, 3, 7, 16, 30, 29))).toEqual('2019年04月07日 16:30:29');
expect(formatter('YYYY年MM月DD日 HH:mm-ss', new Date(2019, 3, 7, 16, 30, 29))).toEqual('2019年04月07日 16:30-29');
expect(formatter('YYYY/MM/DD HH:mm:ss', new Date(2019, 3, 7, 16, 30, 29))).toEqual('2019/04/07 16:30:29');
});

test('should work with delimiters', () => {
Expand Down

0 comments on commit d660ac4

Please sign in to comment.