Cleanup date test with locale offset (#1860)

* Cleanup date test with locale offset

* CHANGELOG

* Add dates to CHANGELOG
This commit is contained in:
Jaco Greeff
2020-02-15 09:49:39 +01:00
committed by GitHub
parent f6b02e1de1
commit 79ee2ede3d
2 changed files with 93 additions and 46 deletions
+6 -4
View File
@@ -39,11 +39,13 @@ describe('Date', (): void => {
testEncode('toU8a', Uint8Array.from([165, 1, 0, 0, 0, 0, 0, 0]));
it('can encode toString', (): void => {
const date = new Date(Date.UTC(1970, 0, 1, 2, 3, 4));
date.setTime(date.getTime() + date.getTimezoneOffset() * 60 * 1000);
expect(
new CodecDate(registry, 421)
.toString()
.startsWith('Thu Jan 01 1970') // The time depends on the timezone this test is run in
).toBe(true);
new CodecDate(registry, date).toString()
).toMatch(/^Thu Jan 01 1970 02:03:04/);
});
it('encodes default BE hex', (): void => {