trezor / trezor-suite

Trezor Suite Monorepo
https://trezor.io/trezor-suite
Other
738 stars 257 forks source link

`groupTransactionsByDate` fails if server is set to Pacific timezone #15534

Open steveluscher opened 6 days ago

steveluscher commented 6 days ago

This unit test passes if your test runner is set to UTC, but fails if it's set to Pacific time.

 FAIL  src/__tests__/transactionUtils.test.ts
  ● transaction utils › groupTransactionsByDate - groupBy day

    expect(received).toEqual(expected) // deep equality

    - Expected  - 2
    + Received  + 0

    @@ -60,12 +60,10 @@
            ],
            "tokens": Array [],
            "txid": "7e58757f43015242c0efa29447bea4583336f2358fdff587b52bbe040ad8982a",
            "type": "sent",
          },
    -   ],
    -   "2019-10-4": Array [
          Object {
            "amount": "1000",
            "blockHash": "00000000000000000017277948d61a631dae6cce1d7fb501301b825599189f51",
            "blockHeight": 2,
            "blockTime": 1570147200,

      53 |             getWalletTransaction({ blockHeight: 0, blockTime: undefined }),
      54 |         ]);
    > 55 |         expect(groupedTxs).toEqual({
        |                            ^
      56 |             'no-blocktime': [
      57 |                 getWalletTransaction({ blockHeight: 0, blockTime: 0 }),
      58 |                 getWalletTransaction({ blockHeight: 0, blockTime: undefined }),

      at Object.toEqual (src/__tests__/transactionUtils.test.ts:55:28)

Repro

sudo timedatectl set-timezone US/Pacific
yarn test:unit