From 395dde5fb62885cb924c1f4aac9faa20ceb4a919 Mon Sep 17 00:00:00 2001 From: majean5 Date: Thu, 10 Nov 2022 20:31:22 +0100 Subject: [PATCH] Corrections --- bob_party/src/core/gameSolo.ts | 4 +- bob_party/src/core/tests/game.test.ts | 68 ++++++++++++++++++++++ bob_party/src/core/tests/match.test.ts | 3 - bob_party/src/core/tests/matchSolo.test.ts | 9 ++- bob_party/src/core/tests/message.test.ts | 2 +- 5 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 bob_party/src/core/tests/game.test.ts delete mode 100644 bob_party/src/core/tests/match.test.ts diff --git a/bob_party/src/core/gameSolo.ts b/bob_party/src/core/gameSolo.ts index ba88a33..5ac5668 100644 --- a/bob_party/src/core/gameSolo.ts +++ b/bob_party/src/core/gameSolo.ts @@ -1,6 +1,6 @@ import { ImageSourcePropType } from 'react-native'; import { Game } from './game' - +/* export class GameSolo extends Game{ readonly ptsToCoins:Map @@ -25,4 +25,4 @@ export class GameSolo extends Game{ } return coins; } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/bob_party/src/core/tests/game.test.ts b/bob_party/src/core/tests/game.test.ts new file mode 100644 index 0000000..12c8372 --- /dev/null +++ b/bob_party/src/core/tests/game.test.ts @@ -0,0 +1,68 @@ +import { Game } from '../Game'; +import { GameSolo } from '../GameSolo'; + + +// Instances + +let myMap = new Map([ + [50, 3], + [75, 4], + [100, 5], + [150, 6] +]); +let game:Game = new GameSolo("id", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap); + + +// Get tests +describe('GameSolo get tests', () => { + it('should return id', () => { + expect(game.getId()).toBe('id'); + }) + it('should return bo jeu', () => { + expect(game.getName()).toBe('bo jeu'); + }) + it('should return require(blackjack.jpg)', () => { + expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg')); + }) + it('should return super jeu', () => { + expect(game.getGameSource()).toBe('super jeu'); + }) + it('should return 1', () => { + expect(game.getNbPlayerMin()).toBe(1); + }) + it('should return 1', () => { + expect(game.getNbPlayerMax()).toBe(1); + }) +}) + + +// 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'); +game.setNbPlayerMin(2); +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'); + }) + it('should return require(JeuDeDame.jpg)', () => { + expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg')); + }) + it('should return trop cool le jeu', () => { + expect(game.getGameSource()).toBe('trop cool le jeu'); + }) + it('should return 2', () => { + expect(game.getNbPlayerMin()).toBe(2); + }) + it('should return 3', () => { + expect(game.getNbPlayerMax()).toBe(3); + }) +}) \ No newline at end of file diff --git a/bob_party/src/core/tests/match.test.ts b/bob_party/src/core/tests/match.test.ts deleted file mode 100644 index 3a561e8..0000000 --- a/bob_party/src/core/tests/match.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Match } from '../Match'; - - diff --git a/bob_party/src/core/tests/matchSolo.test.ts b/bob_party/src/core/tests/matchSolo.test.ts index a85962f..ea8d483 100644 --- a/bob_party/src/core/tests/matchSolo.test.ts +++ b/bob_party/src/core/tests/matchSolo.test.ts @@ -21,7 +21,7 @@ let myMap = new Map([ [150, 6] ]); let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap); -let match = new MatchSolo("machin", tabU, game); +let match = new MatchSolo("machin", false, tabU, game); let tabU2:User[] = []; let game2 = new GameSolo("jeu magnifique", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "wow jeu", 1, 1, myMap) @@ -31,6 +31,9 @@ describe('Match get tests', () => { it('should return machin', () => { expect(match.getCode()).toBe('machin'); }) + it('should return false', () => { + expect(match.getInGame()).toBe(false); + }) it('should return tabU [usr] (users)', () => { expect(match.getTabUsers()).toBe(tabU); }) @@ -42,6 +45,7 @@ describe('Match get tests', () => { // Setting new values match.setGame(game2); +match.setInGame(true); match.setTabUser(tabU2); @@ -50,6 +54,9 @@ describe('Match set tests', () => { it('should return tabU2 [] (users)', () => { expect(match.getTabUsers()).toBe(tabU2); }) + it('should return true', () => { + expect(match.getInGame()).toBe(true); + }) it('should return game2', () => { expect(match.getGame).toBe(game2); }) diff --git a/bob_party/src/core/tests/message.test.ts b/bob_party/src/core/tests/message.test.ts index a4df757..a157f65 100644 --- a/bob_party/src/core/tests/message.test.ts +++ b/bob_party/src/core/tests/message.test.ts @@ -23,7 +23,7 @@ describe('Message get tests', () => { it('should return usr', () => { expect(mess.getMessageSender()).toBe(usr); }) - it('should return wouhou', () => { + it('should return theDate', () => { expect(mess.getMessageDate()).toBe(theDate); }) })