Adding first unit test for score calculation
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2022-09-16 16:43:37 +02:00
parent 4dbc6a2a4d
commit 5f256e1983
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE

View File

@ -1,6 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AddGameComponent } from './add-game.component';
import {Team} from '../../models/doppelkopf/enums/team';
describe('AddGameComponent', () => {
let component: AddGameComponent;
@ -20,4 +21,49 @@ describe('AddGameComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
it('should have the correct score for a normal game', () => {
// Set up testing data
component.actualPlayers = [
{
firebonkId: 1,
uuid: 'abc-def-ghi-j',
firstName: 'Patrick',
team: Team.RE,
gamePoints: 0,
finalCardScore: 123,
},
{
firebonkId: 1,
uuid: 'abc-def-ghi-k',
firstName: 'Julian',
team: Team.RE,
gamePoints: 17,
finalCardScore: 0,
},
{
firebonkId: 1,
uuid: 'abc-def-ghi-l',
firstName: 'Yanick',
team: Team.CONTRA,
gamePoints: 50,
finalCardScore: 0,
},
{
firebonkId: 1,
uuid: 'abc-def-ghi-m',
firstName: 'Janina',
team: Team.CONTRA,
gamePoints: 50,
finalCardScore: 0,
},
]
component.calculateCurrentScores();
expect(component.actualPlayers[0].gamePoints).toEqual(1);
expect(component.actualPlayers[1].gamePoints).toEqual(1);
expect(component.actualPlayers[2].gamePoints).toEqual(-1);
expect(component.actualPlayers[3].gamePoints).toEqual(-1);
})
});