chore: use timestampToDateTime in test
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
DbRelationsRow,
|
||||
} from './tables';
|
||||
import { createRandomRefreshInterval } from '../refresh';
|
||||
import { timestampToDateTime } from './conversion';
|
||||
|
||||
describe('Default Processing Database', () => {
|
||||
const defaultLogger = getVoidLogger();
|
||||
@@ -66,21 +67,6 @@ describe('Default Processing Database', () => {
|
||||
await db<DbRefreshStateRow>('refresh_state').insert(ref);
|
||||
};
|
||||
|
||||
const parseDate = (date: string | Date): DateTime => {
|
||||
const parsedDate =
|
||||
typeof date === 'string'
|
||||
? DateTime.fromSQL(date, { zone: 'UTC' })
|
||||
: DateTime.fromJSDate(date);
|
||||
|
||||
if (!parsedDate.isValid) {
|
||||
throw new Error(
|
||||
`Failed to parse date, reason: ${parsedDate.invalidReason}, explanation: ${parsedDate.invalidExplanation}`,
|
||||
);
|
||||
}
|
||||
|
||||
return parsedDate;
|
||||
};
|
||||
|
||||
describe('addUprocessedEntities', () => {
|
||||
function mockEntity(name: string, type: string): Entity {
|
||||
return {
|
||||
@@ -1010,7 +996,7 @@ describe('Default Processing Database', () => {
|
||||
const result = await knex<DbRefreshStateRow>('refresh_state')
|
||||
.where('entity_ref', 'location:default/new-root')
|
||||
.select();
|
||||
const nextUpdate = parseDate(result[0].next_update_at);
|
||||
const nextUpdate = timestampToDateTime(result[0].next_update_at);
|
||||
const nextUpdateDiff = nextUpdate.diff(now, 'seconds');
|
||||
expect(nextUpdateDiff.seconds).toBeGreaterThanOrEqual(90);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user