feature(database-connection): Add tests for timetracking and add fallback value to max season for fetching stats
This commit is contained in:
71
backend/src/database/timetracking.predicate.spec.ts
Normal file
71
backend/src/database/timetracking.predicate.spec.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { TimeTrackerPredicate } from './timetracking.predicate';
|
||||
import { TimeTrackerStats } from '../models/aliases';
|
||||
|
||||
describe('TimeTrackerPredicate', () => {
|
||||
let timeTrackerPredicate: TimeTrackerPredicate;
|
||||
|
||||
beforeEach(() => {
|
||||
timeTrackerPredicate = new TimeTrackerPredicate();
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(timeTrackerPredicate).toBeDefined();
|
||||
});
|
||||
|
||||
it('should process UserStats properly to TableEntry', () => {
|
||||
const input: TimeTrackerStats[] = [
|
||||
{
|
||||
entry_id: 1,
|
||||
user_uid: 'TEST_UUID1',
|
||||
season_id: 1,
|
||||
rank_id: 1,
|
||||
time: 12345,
|
||||
user: {
|
||||
uid: 'TEST_UUID1',
|
||||
name: 'Test User 1'
|
||||
},
|
||||
ranks: {
|
||||
entry_id: 1,
|
||||
season_id: 1,
|
||||
rank_id: 1,
|
||||
rank_name: 'Test Rank 1'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry_id: 2,
|
||||
user_uid: 'TEST_UUID2',
|
||||
season_id: 1,
|
||||
rank_id: 2,
|
||||
time: 123455,
|
||||
user: {
|
||||
uid: 'TEST_UUID2',
|
||||
name: 'Test User 2'
|
||||
},
|
||||
ranks: {
|
||||
entry_id: 1,
|
||||
season_id: 1,
|
||||
rank_id: 2,
|
||||
rank_name: 'Test Rank 2'
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
const expected = [
|
||||
{
|
||||
name: 'Test User 2',
|
||||
onlineTime: "1d 10h 17m 35s",
|
||||
rank: 'Test Rank 2',
|
||||
rawTime: 123455
|
||||
},
|
||||
{
|
||||
name: 'Test User 1',
|
||||
onlineTime: "0d 3h 25m 45s",
|
||||
rank: 'Test Rank 1',
|
||||
rawTime: 12345
|
||||
}
|
||||
];
|
||||
|
||||
const actual = timeTrackerPredicate.process(input);
|
||||
expect(actual).toEqual(expected);
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user