Skip to content

Commit

Permalink
Fix dashboard tests (#8715)
Browse files Browse the repository at this point in the history
Fix failing `AssetQuery` test

# Important Notes
None
  • Loading branch information
somebody1234 authored Jan 9, 2024
1 parent b201577 commit b8f4dc3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import * as assetQuery from '../assetQuery'

v.test.each([
{ query: '' },
{ query: 'name:' },
{ query: '-name:' },
{ query: 'label:' },
{ query: '-label:' },
{ query: 'owner:' },
{ query: '-owner:' },
{ query: 'name:', names: [[]] },
{ query: '-name:', negativeNames: [[]] },
{ query: 'label:', labels: [[]] },
{ query: '-label:', negativeLabels: [[]] },
{ query: 'owner:', owners: [[]] },
{ query: '-owner:', negativeOwners: [[]] },
{ query: '"', keywords: [['']] },
{ query: '""', keywords: [['']] },
{ query: 'a', keywords: [['a']] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,30 @@ import * as dateTime from '../dateTime'

/* eslint-disable @typescript-eslint/no-magic-numbers */

/** The number of milliseconds in an hour. */
const HOUR_MS = 3_600_000
/** The number of minutes in an hour. */
const HOUR_MIN = 60
const TIMEZONE_OFFSET_MINS = new Date().getTimezoneOffset()
/** The offset of local time */
const TIMEZONE_OFFSET_HOURS = new Date().getTimezoneOffset() / HOUR_MIN
const TIMEZONE_OFFSET_HOURS = Math.floor(TIMEZONE_OFFSET_MINS / HOUR_MIN)

v.test.each([
{ date: new Date(0), string: '1970-01-01T00:00:00.000Z', chatString: '01/01/1970 10:00 AM' },
{ date: new Date(0), string: '1970-01-01T00:00:00.000Z' },
{
date: new Date(2001, 1, 3, -TIMEZONE_OFFSET_HOURS),
string: '2001-02-03T00:00:00.000Z',
chatString: '03/02/2001 10:00 AM',
},
])('Date and time serialization', ({ date, string, chatString }) => {
])('Date and time serialization', ({ date, string }) => {
v.expect(dateTime.toRfc3339(date)).toBe(string)
})

v.test.each([
{ date: new Date(TIMEZONE_OFFSET_HOURS * HOUR_MS), chatString: `01/01/1970 00:00 AM` },
{
date: new Date(2001, 1, 3),
chatString: `03/02/2001 00:00 AM`,
},
])('Date and time serialization', ({ date, chatString }) => {
v.expect(dateTime.formatDateTimeChatFriendly(date)).toBe(chatString)
})

0 comments on commit b8f4dc3

Please sign in to comment.