Skip to content

Commit

Permalink
test(app-project): refactor YourStats tests to a non-UTC timezone
Browse files Browse the repository at this point in the history
A couple of small refactors for the `YourStats` tests:
- add missing timestamps to the mock ERAS data, to match real ERAS responses.
- test the weekly stats in the `-05:00` timezone, to check for timezone bugs.
  • Loading branch information
eatyourgreens committed Oct 29, 2024
1 parent 963abe8 commit 4fdec87
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { talkAPI } from '@zooniverse/panoptes-js'
import initStore from '@stores/initStore'
import YourStats, { statsClient } from './YourStats'

describe('Stores > YourStats', function () {
describe.only('Stores > YourStats', function () {
let rootStore, nockScope
const project = {
id: '2',
Expand All @@ -20,14 +20,14 @@ describe('Stores > YourStats', function () {
sinon.stub(console, 'error')

const MOCK_DAILY_COUNTS = [
{ count: 12, period: '2019-09-29' },
{ count: 12, period: '2019-09-30' },
{ count: 13, period: '2019-10-01' },
{ count: 14, period: '2019-10-02' },
{ count: 10, period: '2019-10-03' },
{ count: 11, period: '2019-10-04' },
{ count: 8, period: '2019-10-05' },
{ count: 15, period: '2019-10-06' }
{ count: 12, period: '2019-09-29T00:00:00.000Z' },
{ count: 12, period: '2019-09-30T00:00:00.000Z' },
{ count: 13, period: '2019-10-01T00:00:00.000Z' },
{ count: 14, period: '2019-10-02T00:00:00.000Z' },
{ count: 10, period: '2019-10-03T00:00:00.000Z' },
{ count: 11, period: '2019-10-04T00:00:00.000Z' },
{ count: 8, period: '2019-10-05T00:00:00.000Z' },
{ count: 15, period: '2019-10-06T00:00:00.000Z' }
]

nockScope = nock('https://panoptes-staging.zooniverse.org/api')
Expand Down Expand Up @@ -67,7 +67,9 @@ describe('Stores > YourStats', function () {
let clock

before(function () {
clock = sinon.useFakeTimers({ now: new Date(2019, 9, 1, 12), toFake: ['Date'] })
// Set the local clock to 1am on Tuesday 1 October 2019, UTC.
// Stats should be shown for Monday 30 September 2019, local time.
clock = sinon.useFakeTimers(new Date('2019-09-30T20:00:00-05:00'))
const user = {
id: '123',
login: 'test.user'
Expand Down

0 comments on commit 4fdec87

Please sign in to comment.