Skip to content

Commit bd871ce

Browse files
committed
feat: update test case
1 parent 99a78ed commit bd871ce

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/generateWithTZ.spec.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ describe('dayjs: getNow', () => {
3838
const M_now = moment().tz(JP);
3939

4040
expect(D_now.format()).toEqual(M_now.format());
41-
expect(D_now.get('hour') - D_now.utc().get('hour')).toEqual(9);
41+
42+
const expectedOffset = M_now.utcOffset() / 60;
43+
const actualOffset = D_now.get('hour') - D_now.utc().get('hour');
44+
45+
let normalizedOffset = actualOffset;
46+
if (actualOffset > 12) {
47+
normalizedOffset = actualOffset - 24;
48+
} else if (actualOffset < -12) {
49+
normalizedOffset = actualOffset + 24;
50+
}
51+
expect(normalizedOffset).toEqual(expectedOffset);
4252
});
4353
});

0 commit comments

Comments
 (0)