72 lines
1.6 KiB
TypeScript
72 lines
1.6 KiB
TypeScript
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);
|
|
})
|
|
});
|