Skip to content

Commit 2a16140

Browse files
authored
test: Update week test case (#16)
1 parent 56474a7 commit 2a16140

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

src/generate/moment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const generateConfig: GenerateConfig<Moment> = {
9595
let formatText = text;
9696

9797
if (format.includes('wo') || format.includes('Wo')) {
98-
format = format.replace(/wo/g, 'ww').replace(/Wo/g, 'WW');
98+
format = format.replace(/wo/g, 'w').replace(/Wo/g, 'W');
9999
const matchFormat = format.match(/[-YyMmDdHhSsWwGg]+/g);
100100
const matchText = formatText.match(/[-\d]+/g);
101101

tests/generate.spec.tsx

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,40 @@ describe('Picker.Generate', () => {
6464
});
6565

6666
describe('locale', () => {
67-
it('parse', () => {
68-
['2000-01-02', '02/01/2000'].forEach(str => {
69-
const date = generateConfig.locale.parse('en_US', str, [
70-
'YYYY-MM-DD',
71-
'DD/MM/YYYY',
72-
]);
67+
describe('parse', () => {
68+
it('basic', () => {
69+
['2000-01-02', '02/01/2000'].forEach(str => {
70+
const date = generateConfig.locale.parse('en_US', str, [
71+
'YYYY-MM-DD',
72+
'DD/MM/YYYY',
73+
]);
74+
75+
expect(
76+
generateConfig.locale.format('en_US', date!, 'YYYY-MM-DD'),
77+
).toEqual('2000-01-02');
78+
});
79+
});
7380

81+
it('week', () => {
7482
expect(
75-
generateConfig.locale.format('en_US', date!, 'YYYY-MM-DD'),
76-
).toEqual('2000-01-02');
83+
generateConfig.locale.format(
84+
'en_US',
85+
generateConfig.locale.parse('en_US', '2019-1st', [
86+
'gggg-wo',
87+
])!,
88+
'gggg-wo',
89+
),
90+
).toEqual('2019-1st');
91+
92+
expect(
93+
generateConfig.locale.format(
94+
'zh_CN',
95+
generateConfig.locale.parse('zh_CN', '2019-45周', [
96+
'gggg-wo',
97+
])!,
98+
'gggg-wo',
99+
),
100+
).toEqual('2019-45周');
77101
});
78102
});
79103

0 commit comments

Comments
 (0)