tests unitaires (corrections, ajouts)
continuous-integration/drone/push Build is failing Details

typescript^2^2
Mathilde JEAN 2 years ago
parent b3d113cbec
commit d7c9b36ce2

@ -67,6 +67,6 @@ export abstract class Match{
}
abstract updatePostMatch(user:User, coins:number):void;
abstract updatePostMatch(user:User, points:number):void;
}

@ -10,9 +10,9 @@ export class MatchMulti extends Match{
super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, coins: number): void {
updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(coins));
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -10,8 +10,8 @@ export class MatchMulti extends Match{
super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, coins: number): void {
updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(coins));
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -10,8 +10,8 @@ export class MatchSolo extends Match{
super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, coins: number): void {
updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(coins));
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -1,3 +1,4 @@
import exp from 'constants';
import { Conversation } from '../Conversation';
import { Message } from '../Message';
import { Skin } from '../Skin';
@ -42,6 +43,8 @@ describe('Conversation get tests', () => {
// Setting new value
convo.setName('THE conv');
convo.ajouterUser(usr3);
convo.ajouterMessage(mess3);
// Set test
@ -49,4 +52,13 @@ describe('Conversation set test', () => {
it('should return THE conv', () => {
expect(convo.setName).toBe('THE conv');
})
it('should return tabU [usr, usr2, usr3] (users)', () => {
expect(convo.getTabUser()).toBe(tabU);
})
it('should return tabM [mess, mess2, mess3] (messages)', () => {
expect(convo.getTabMessage()).toBe(tabM);
})
it('should return Mais oui trop de ouf (mess3)', () => {
expect(convo.getLastMessage()).toBe('Mais oui trop de ouf');
})
})

@ -37,7 +37,6 @@ describe('GameSolo get tests', () => {
// Setting new values
game.setId('newId');
game.setGameSource('trop cool le jeu');
game.setImageSource(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
game.setName('beau jeu');
@ -47,9 +46,6 @@ game.setNbPlayerMax(3);
// Set tests
describe('GameSolo set tests', () => {
it('should return newId', () => {
expect(game.getId()).toBe('newId');
})
it('should return beau jeu', () => {
expect(game.getName()).toBe('beau jeu');
})

@ -3,7 +3,7 @@ import { GameCasino } from '../GameCasino';
// Instances
let game = new GameCasino("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5);
let game = new GameCasino("GC001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5);
// Get tests
@ -51,3 +51,12 @@ describe('GameCasino set tests', () => {
it('should return 4', () => {
expect(game.getNbPlayerMin()).toBe(4);
})
})
// Coins Calculator Tests
describe('Coins calculator tests', () => {
it('should return 200', () => {
expect(game.coinsCalculator(200)).toBe(200);
})
})

@ -6,16 +6,19 @@ import { GameCasino } from '../GameCasino';
// Instances
let myMap = new Map<number, number>([
[50, 3],
[75, 4],
[100, 5],
[150, 6]
[4, 1],
[3, 3],
[2, 5],
[1, 10]
]);
let game = new GameMulti("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5, myMap);
let game = new GameMulti("GM001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5, myMap);
// Get tests
describe('GameMuti get tests', () => {
it('should return GM001', () => {
expect(game.getId()).toBe('GM001');
})
it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu');
})
@ -63,3 +66,20 @@ describe('GameMulti set tests', () => {
expect(game.getNbPlayerMin()).toBe(4);
})
})
// Coins Calculator tests
describe('Coins calculator tests', () => {
it('should return 1', () => {
expect(game.coinsCalculator(4)).toBe(1);
})
it('should return 3', () => {
expect(game.coinsCalculator(3)).toBe(3);
})
it('should return 5', () => {
expect(game.coinsCalculator(2)).toBe(5);
})
it('should return 10', () => {
expect(game.coinsCalculator(1)).toBe(10);
})
})

@ -1,3 +1,4 @@
import exp from 'constants';
import { GameSolo } from '../GameSolo';
// Instances
@ -7,11 +8,14 @@ let myMap = new Map<number, number>([
[100, 5],
[150, 6]
]);
let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
let game=new GameSolo("G0001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
// Get tests
describe('GameSolo get tests', () => {
it('should return G0001', () => {
expect(game.getId()).toBe('G0001');
})
it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu');
})
@ -59,3 +63,20 @@ describe('GameSolo set tests', () => {
expect(game.getNbPlayerMax()).toBe(3);
})
})
// Coins Calculator tests
describe('Coins calculator tests', () => {
it('should return 3', () => {
expect(game.coinsCalculator(50)).toBe(3);
})
it('should return 4', () => {
expect(game.coinsCalculator(75)).toBe(4);
})
it('should return 5', () => {
expect(game.coinsCalculator(100)).toBe(5);
})
it('should return 6', () => {
expect(game.coinsCalculator(150)).toBe(6);
})
})

@ -11,8 +11,8 @@ let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/Bob
let blue = new Skin("S0002", "Bob Blue", require('bob_party/assets/BobsSkins/BobBlue.png'), 100);
let tab:Skin[] = [classique, blue];
let dateBirth = new Date(2010,0o3,0o7);
let conv:Conversation[] = [];
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
let usr2 = new User('00002', 'Rémi', 'pwd', 'Martinique', 'M', dateBirth, 0, 0, 0, classique, tab);
let tabU:User[] = [usr];
let myMap = new Map<number, number>([
[50, 3],
@ -61,3 +61,24 @@ describe('Match set tests', () => {
expect(match.getGame).toBe(game2);
})
})
// Update Post-Match tests
describe('Update post-match tests', () => {
it('should return 3', () => {
match.updatePostMatch(tabU[0],50);
expect(tabU[0].getCurrentCoins()).toBe(3);
})
it('should return 8', () => {
match.updatePostMatch(tabU[0],100);
expect(tabU[0].getCurrentCoins()).toBe(8);
})
it('should return 4', () => {
match.updatePostMatch(usr2,75);
expect(usr2.getCurrentCoins()).toBe(4);
})
it('should return 10', () => {
match.updatePostMatch(usr2,150);
expect(usr2.getCurrentCoins()).toBe(10);
})
})

@ -8,8 +8,8 @@ let conv:Conversation[] = [];
let tab:Skin[] = [];
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
let dateBirth = new Date(2010,0o3,0o7);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv);
let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab, conv);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab);
let theDate = new Date(2022,10,14);
let theDate2 = new Date(2022,10,13);
let mess = new Message('Bob Party est le meilleur projet', usr, theDate);

Loading…
Cancel
Save