From 99ac169e5eed894a87a929d6f6457dc24e3cde91 Mon Sep 17 00:00:00 2001 From: majean5 Date: Tue, 6 Dec 2022 17:49:39 +0100 Subject: [PATCH] correctinos tests unitaires --- bob_party/jest.config.js | 1 + bob_party/src/constUser.ts | 10 ++--- bob_party/src/core/Auth/newUser.ts | 2 +- bob_party/src/core/Game.ts | 4 -- bob_party/src/core/gameCasino.ts | 1 - bob_party/src/core/gameMulti.ts | 1 - bob_party/src/core/gameSolo.ts | 1 - bob_party/src/core/tests/conversation.test.ts | 31 ++++++------- bob_party/src/core/tests/gameCasino.test.ts | 2 +- bob_party/src/core/tests/gameMulti.test.ts | 33 +++++++------- bob_party/src/core/tests/gameSolo.test.ts | 31 ++++++------- bob_party/src/core/tests/matchSolo.test.ts | 20 ++++----- bob_party/src/core/tests/message.test.ts | 12 ++--- bob_party/src/core/tests/skin.test.ts | 10 ++--- bob_party/src/core/tests/users.test.ts | 45 +++++++++---------- .../managerConversation.ts | 1 - .../src/services/tests/loaderUserApi.test.ts | 14 +++--- bob_party/src/services/tests/stubUser.test.ts | 22 ++++----- bob_party/src/testGameSolo.ts | 2 +- 19 files changed, 111 insertions(+), 132 deletions(-) diff --git a/bob_party/jest.config.js b/bob_party/jest.config.js index 135cf40..2f910ec 100644 --- a/bob_party/jest.config.js +++ b/bob_party/jest.config.js @@ -2,4 +2,5 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', testMatch: ["**/__tests__/**/*.ts?(x)", "**/?(*.)+(test).ts?(x)"], + transformIgnorePatterns: ['/node_modules/(?!(foo|bar)/)', '/bar/'], }; \ No newline at end of file diff --git a/bob_party/src/constUser.ts b/bob_party/src/constUser.ts index d7fb6c5..a119883 100644 --- a/bob_party/src/constUser.ts +++ b/bob_party/src/constUser.ts @@ -1,13 +1,11 @@ -import { Message } from "./core/message" -import { Conversation } from "./core/conversation" import tabSkinApp from './constSkin' import { User } from "./core/User/user"; -let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp); -let Alban:User=new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, tabSkinApp[1], tabSkinApp); -let Fefe63:User=new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp); -let UserTest:User=new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[2], tabSkinApp); +let UserActu:User=new User(14, "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp); +let Alban:User=new User(17, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, tabSkinApp[1], tabSkinApp); +let Fefe63:User=new User(18, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp); +let UserTest:User=new User(48, "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[2], tabSkinApp); let tabUS:User[]=[UserTest, Alban, UserActu, Fefe63]; diff --git a/bob_party/src/core/Auth/newUser.ts b/bob_party/src/core/Auth/newUser.ts index d8a357c..5328222 100644 --- a/bob_party/src/core/Auth/newUser.ts +++ b/bob_party/src/core/Auth/newUser.ts @@ -64,7 +64,7 @@ export const checkNewUserValidity = (login: string, password: string, dateOfBirt break; default: - const newUser : User = new User("0",login,password,nationality,sexe,dateOfBirth); + const newUser : User = new User(0,login,password,nationality,sexe,dateOfBirth); dispatch(loginUser(newUser)); nav.navigate('HomeTab'); } diff --git a/bob_party/src/core/Game.ts b/bob_party/src/core/Game.ts index 337c734..17464c5 100644 --- a/bob_party/src/core/Game.ts +++ b/bob_party/src/core/Game.ts @@ -1,7 +1,3 @@ -import { randomBytes } from "crypto"; -import { ImageSourcePropType } from "react-native"; -import internal from "stream"; - export abstract class Game{ readonly id:number; private name:string; diff --git a/bob_party/src/core/gameCasino.ts b/bob_party/src/core/gameCasino.ts index 92d1ba8..379166d 100644 --- a/bob_party/src/core/gameCasino.ts +++ b/bob_party/src/core/gameCasino.ts @@ -1,4 +1,3 @@ -import { ImageSourcePropType } from 'react-native'; import { Game } from './game' export class GameCasino extends Game{ diff --git a/bob_party/src/core/gameMulti.ts b/bob_party/src/core/gameMulti.ts index b897be5..bbaad4f 100644 --- a/bob_party/src/core/gameMulti.ts +++ b/bob_party/src/core/gameMulti.ts @@ -1,4 +1,3 @@ -import { ImageSourcePropType } from 'react-native'; import { Game } from './game' export class GameMulti extends Game{ diff --git a/bob_party/src/core/gameSolo.ts b/bob_party/src/core/gameSolo.ts index 5ebcf59..50ede0f 100644 --- a/bob_party/src/core/gameSolo.ts +++ b/bob_party/src/core/gameSolo.ts @@ -1,4 +1,3 @@ -import { ImageSourcePropType } from 'react-native'; import { Game } from './game' export class GameSolo extends Game{ diff --git a/bob_party/src/core/tests/conversation.test.ts b/bob_party/src/core/tests/conversation.test.ts index 84c5c09..79046c6 100644 --- a/bob_party/src/core/tests/conversation.test.ts +++ b/bob_party/src/core/tests/conversation.test.ts @@ -5,9 +5,8 @@ import { User } from '../User/user'; // Instances -const img = ""; let tab:Skin[] = []; -new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0); +let classique = new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0); let dateBirth = new Date(2010,0o3,0o7); let usr = new User(1, 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); let usr2 = new User(2, 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab); @@ -19,48 +18,46 @@ let tabU:User[] = [usr, usr2]; let mess2 = new Message(2, 'Oui tout à fait', usr2, theDate); let mess3 = new Message(3, 'Mais oui trop de ouf', usr, theDate3); let tabM:Message[] = [mess, mess2]; +let tabM2:Message[] = [mess, mess2, mess3]; let convo = new Conversation(1, tabU, tabM, 'the conv'); let usr3 = new User(4, 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); // Get tests describe('Conversation get tests', () => { - it('should return C0001', () => { - expect(convo.getId()).toBe('C0001'); + it('should return 1', () => { + expect(convo.getId()).toBe(1); }) it('should return the conv', () => { expect(convo.getName()).toBe('the conv'); }) it('should return tabU [usr, usr2] (users)', () => { - expect(convo.getTabUser()).toBe(tabU); + expect(convo.getTabUser()).toEqual(tabU); }) it('should return tabM [mess, mess2] (messages)', () => { - expect(convo.getTabMessage()).toBe(tabM); + expect(convo.getTabMessage()).toEqual(tabM); }) it('should return Oui tout à fait (mess2)', () => { - expect(convo.getLastMessage()).toBe('Oui tout à fait'); + expect(convo.getLastMessage()).toEqual(mess2); }) }) -// Setting new value -convo.setName('THE conv'); -convo.ajouterUser(usr3); -convo.ajouterMessage(mess3); - - // Set test describe('Conversation set test', () => { it('should return THE conv', () => { - expect(convo.setName).toBe('THE conv'); + convo.setName('THE conv'); + expect(convo.getName()).toBe('THE conv'); }) it('should return tabU [usr, usr2, usr3] (users)', () => { - expect(convo.getTabUser()).toBe(tabU); + convo.ajouterUser(usr3); + expect(convo.getTabUser()).toEqual(tabU); }) it('should return tabM [mess, mess2, mess3] (messages)', () => { - expect(convo.getTabMessage()).toBe(tabM); + convo.ajouterMessage(mess3); + expect(convo.getTabMessage()).toEqual(tabM2); }) it('should return Mais oui trop de ouf (mess3)', () => { - expect(convo.getLastMessage()).toBe('Mais oui trop de ouf'); + expect(convo.getLastMessage()).toEqual(mess3); }) }) \ No newline at end of file diff --git a/bob_party/src/core/tests/gameCasino.test.ts b/bob_party/src/core/tests/gameCasino.test.ts index c901631..c5dba07 100644 --- a/bob_party/src/core/tests/gameCasino.test.ts +++ b/bob_party/src/core/tests/gameCasino.test.ts @@ -4,7 +4,7 @@ import { GameCasino } from '../GameCasino'; // Instances const img = ""; -let game = new GameCasino("GC001", "bo jeu", img, "super jeu", 1, 5); +let game = new GameCasino(1, "bo jeu", img, "super jeu", 1, 5); // Get tests diff --git a/bob_party/src/core/tests/gameMulti.test.ts b/bob_party/src/core/tests/gameMulti.test.ts index 91cd181..9e72a63 100644 --- a/bob_party/src/core/tests/gameMulti.test.ts +++ b/bob_party/src/core/tests/gameMulti.test.ts @@ -9,19 +9,19 @@ let myMap = new Map([ [2, 5], [1, 10] ]); -let game = new GameMulti("GM001", "bo jeu", img, "super jeu", 1, 5, myMap); +let game = new GameMulti(1, "bo jeu", img, "super jeu", 1, 5, myMap); // Get tests -describe('GameMuti get tests', () => { - it('should return GM001', () => { - expect(game.getId()).toBe('GM001'); +describe('GameMulti get tests', () => { + it('should return 1', () => { + expect(game.getId()).toBe(1); }) it('should return bo jeu', () => { expect(game.getName()).toBe('bo jeu'); }) it('should return require(blackjack.jpg)', () => { - expect(game.getImageSource()).toBe(img); + expect(game.getImageSource()).toEqual(img); }) it('should return super jeu', () => { expect(game.getGameSource()).toBe('super jeu'); @@ -33,41 +33,38 @@ describe('GameMuti get tests', () => { expect(game.getNbPlayerMax()).toBe(5); }) it('should return myMap', () => { - expect(game.getMultiMap()).toBe(myMap); + expect(game.getMultiMap()).toEqual(myMap); }) }) -// Setting new values -game.setGameSource('trop cool le jeu'); -game.setImageSource(img); -game.setName('beau jeu'); -game.setNbPlayerMin(2); -game.setNbPlayerMax(4); - - // Set tests describe('GameMulti set tests', () => { it('should return beau jeu', () => { + game.setName('beau jeu'); expect(game.getName()).toBe('beau jeu'); }) - it('should return require(JeuDeDame.jpg)', () => { - expect(game.getImageSource).toBe(img); + it('should return img ("")', () => { + game.setImageSource(img); + expect(game.getImageSource()).toEqual(img); }) it('should return trop cool le jeu', () => { + game.setGameSource('trop cool le jeu'); expect(game.getGameSource()).toBe('trop cool le jeu'); }) it('should return trop cool le jeu', () => { + game.setNbPlayerMin(2); expect(game.getNbPlayerMin()).toBe(2); }) it('should return 4', () => { - expect(game.getNbPlayerMin()).toBe(4); + game.setNbPlayerMax(4); + expect(game.getNbPlayerMax()).toBe(4); }) }) // Coins Calculator tests -describe('Coins calculator tests', () => { +describe('GameMulti coins calculator tests', () => { it('should return 1', () => { expect(game.coinsCalculator(4)).toBe(1); }) diff --git a/bob_party/src/core/tests/gameSolo.test.ts b/bob_party/src/core/tests/gameSolo.test.ts index adaa06f..8208ca3 100644 --- a/bob_party/src/core/tests/gameSolo.test.ts +++ b/bob_party/src/core/tests/gameSolo.test.ts @@ -8,19 +8,19 @@ let myMap = new Map([ [100, 5], [150, 6] ]); -let game=new GameSolo("G0001", "bo jeu", img, "super jeu", 1, 1, myMap); +let game=new GameSolo(1, "bo jeu", img, "super jeu", 1, 1, myMap); // Get tests describe('GameSolo get tests', () => { - it('should return G0001', () => { - expect(game.getId()).toBe('G0001'); + it('should return 1', () => { + expect(game.getId()).toBe(1); }) it('should return bo jeu', () => { expect(game.getName()).toBe('bo jeu'); }) - it('should return require(blackjack.jpg)', () => { - expect(game.getImageSource()).toBe(img); + it('should return blackjack.jpg', () => { + expect(game.getImageSource()).toEqual(img); }) it('should return super jeu', () => { expect(game.getGameSource()).toBe('super jeu'); @@ -32,41 +32,38 @@ describe('GameSolo get tests', () => { expect(game.getNbPlayerMax()).toBe(1); }) it('should return myMap', () => { - expect(game.getSoloMap()).toBe(myMap); + expect(game.getSoloMap()).toEqual(myMap); }) }) -// Setting new values -game.setGameSource('trop cool le jeu'); -game.setImageSource(img); -game.setName('beau jeu'); -game.setNbPlayerMin(2); -game.setNbPlayerMax(3); - - // Set tests describe('GameSolo set tests', () => { it('should return beau jeu', () => { + game.setName('beau jeu'); expect(game.getName()).toBe('beau jeu'); }) - it('should return require(JeuDeDame.jpg)', () => { - expect(game.getImageSource).toBe(img); + it('should return JeuDeDame.jpg', () => { + game.setImageSource(img); + expect(game.getImageSource()).toEqual(img); }) it('should return trop cool le jeu', () => { + game.setGameSource('trop cool le jeu'); expect(game.getGameSource()).toBe('trop cool le jeu'); }) it('should return 2', () => { + game.setNbPlayerMin(2); expect(game.getNbPlayerMin()).toBe(2); }) it('should return 3', () => { + game.setNbPlayerMax(3); expect(game.getNbPlayerMax()).toBe(3); }) }) // Coins Calculator tests -describe('Coins calculator tests', () => { +describe('GameSolo coins calculator tests', () => { it('should return 3', () => { expect(game.coinsCalculator(50)).toBe(3); }) diff --git a/bob_party/src/core/tests/matchSolo.test.ts b/bob_party/src/core/tests/matchSolo.test.ts index e29855e..c2cc7b8 100644 --- a/bob_party/src/core/tests/matchSolo.test.ts +++ b/bob_party/src/core/tests/matchSolo.test.ts @@ -1,4 +1,4 @@ -import { MatchSolo } from '../Match/matchSolo'; +import MatchSolo from '../Match/matchSolo'; import { Conversation } from '../Conversation'; import { Skin } from '../Skin'; import { User } from '../User/user'; @@ -8,12 +8,12 @@ import { GameSolo } from '../GameSolo'; // Instances const img = ""; -let classique = new Skin("S0001", "Bob", img, 0); -let blue = new Skin("S0002", "Bob Blue", img, 100); +let classique = new Skin(1, "Bob", img, 0); +let blue = new Skin(2, "Bob Blue", img, 100); let tab:Skin[] = [classique, blue]; let dateBirth = new Date(2010,0o3,0o7); -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 usr = new User(1, 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); +let usr2 = new User(2, 'Rémi', 'pwd', 'Martinique', 'M', dateBirth, 0, 0, 0, classique, tab); let tabU:User[] = [usr]; let myMap = new Map([ [50, 3], @@ -21,16 +21,16 @@ let myMap = new Map([ [100, 5], [150, 6] ]); -let game=new GameSolo("G0001", "bo jeu", img, "super jeu", 1, 1, myMap); -let match = new MatchSolo("machin", false, tabU, game); +let game=new GameSolo(1, "bo jeu", img, "super jeu", 1, 1, myMap); +let match = new MatchSolo(1, false, tabU, game); let tabU2:User[] = []; -let game2 = new GameSolo("G0002", "jeu magnifique", img, "wow jeu", 1, 1, myMap) +let game2 = new GameSolo(2, "jeu magnifique", img, "wow jeu", 1, 1, myMap) // Get tests describe('Match get tests', () => { - it('should return machin', () => { - expect(match.getCode()).toBe('machin'); + it('should return 1', () => { + expect(match.getCode()).toBe(1); }) it('should return false', () => { expect(match.getInGame()).toBe(false); diff --git a/bob_party/src/core/tests/message.test.ts b/bob_party/src/core/tests/message.test.ts index 962e2c2..8f3b0f9 100644 --- a/bob_party/src/core/tests/message.test.ts +++ b/bob_party/src/core/tests/message.test.ts @@ -4,19 +4,19 @@ import { Skin } from '../Skin'; // Instances const img = ""; -let classique = new Skin("S0001", "Bob", img, 0); +let classique = new Skin(1, "Bob", img, 0); let dateBirth = new Date(2010,0o3,0o7); -let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, []); -let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, []); +let usr = new User(1, 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, []); +let usr2 = new User(2, 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, []); let theDate = new Date(2022,10,14); let theDate2 = new Date(2022,10,13); -let mess = new Message('M0001', 'Bob Party est le meilleur projet', usr, theDate); +let mess = new Message(1, 'Bob Party est le meilleur projet', usr, theDate); // Get tests describe('Message get tests', () => { - it('should return M0001', () => { - expect(mess.getMessageId()).toBe('M0001'); + it('should return 1', () => { + expect(mess.getMessageId()).toBe(1); }) it('should return Bob Party est le meilleur projet', () => { expect(mess.getMessageContent()).toBe('Bob Party est le meilleur projet'); diff --git a/bob_party/src/core/tests/skin.test.ts b/bob_party/src/core/tests/skin.test.ts index 434c191..af6d1dc 100644 --- a/bob_party/src/core/tests/skin.test.ts +++ b/bob_party/src/core/tests/skin.test.ts @@ -4,21 +4,21 @@ import { Skin } from '../Skin'; // Instance const img = ""; -let classique = new Skin("S0001", "Bob", img, 0); +let classique = new Skin(1, "Bob", img, 0); // Get tests describe('Skin get tests', () => { - it('should return S0001', () => { - expect(classique.getSkinId()).toBe('S0001'); + it('should return 1', () => { + expect(classique.getSkinId()).toBe(1); }) it('should return Bob', () => { expect(classique.getSkinName()).toEqual('Bob'); }) - it('should return require(BobClassic.png)', () => { - expect(classique.getSkinSource()).toEqual(require(img)); + it('should return img ("")', () => { + expect(classique.getSkinSource()).toEqual(img); }) it('should return 0', () => { expect(classique.getSkinCost()).toBe(0); diff --git a/bob_party/src/core/tests/users.test.ts b/bob_party/src/core/tests/users.test.ts index ba55192..5910727 100644 --- a/bob_party/src/core/tests/users.test.ts +++ b/bob_party/src/core/tests/users.test.ts @@ -4,19 +4,19 @@ import { Skin } from '../Skin'; // Instances const img = ""; -let classique = new Skin("S0001", "Bob", img, 0); -let blue = new Skin("S0002", "Bob Blue", img, 100); +let classique = new Skin(1, "Bob", img, 0); +let blue = new Skin(2, "Bob Blue", img, 100); let tab:Skin[] = []; let tab2:Skin[] = [classique, blue]; let dateBirth = new Date(2010,0o3,0o7); let dateBirth2 = new Date(2009,0o3,0o7); -let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); +let usr = new User(1, 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); // Tests des get describe('User get tests', () => { - it('should return 00001', () => { - expect(usr.getId()).toBe('00001'); + it('should return 1', () => { + expect(usr.getId()).toBe(1); }) it('should return Killyan', () => { expect(usr.getUsername()).toBe('Killyan'); @@ -31,7 +31,7 @@ describe('User get tests', () => { expect(usr.getSexe()).toBe('M'); }) it('should return 2010-03-07 (dateBirth)', () => { - expect(usr.getDateOfBirth()).toBe(dateBirth); + expect(usr.getDateOfBirth()).toEqual(dateBirth); }) it('should return 0', () => { expect(usr.getCurrentCoins()).toBe(0); @@ -43,57 +43,54 @@ describe('User get tests', () => { expect(usr.getGamesPlayed()).toBe(0); }) it('should return classique', () => { - expect(usr.getCurrentSkin()).toBe(classique); + expect(usr.getCurrentSkin()).toEqual(classique); }) it('should return tab', () => { - expect(usr.getTabSkin()).toBe(tab); + expect(usr.getTabSkin()).toEqual(tab); }) }) -// Set de nouvelles valeurs -usr.setUsername('BgKillyan'); -usr.setPassword('1234'); -usr.setNationality('Marseille'); -usr.setSexe('F'); -usr.setDateOfBirth(dateBirth2); -usr.setCurrentCoins(2); -usr.setTotalCoins(2); -usr.setGamesPlayed(4); -usr.setCurrentSkin(blue); -usr.setTabSkin(tab2); - - // Tests des set describe('User get tests', () => { it('should return BgKillyan', () => { + usr.setUsername('BgKillyan'); expect(usr.getUsername()).toBe('BgKillyan'); }) it('should return 1234', () => { + usr.setPassword('1234'); expect(usr.getPassword()).toBe('1234'); }) it('should return Marseille', () => { + usr.setNationality('Marseille'); expect(usr.getNationality()).toBe('Marseille'); }) it('should return F', () => { + usr.setSexe('F'); expect(usr.getSexe()).toBe('F'); }) it('should return 07/03/2009 (dateBirth2)', () => { - expect(usr.getDateOfBirth()).toBe(dateBirth2); + usr.setDateOfBirth(dateBirth2); + expect(usr.getDateOfBirth()).toEqual(dateBirth2); }) it('should return 2', () => { + usr.setCurrentCoins(2); expect(usr.getCurrentCoins()).toBe(2); }) it('should return 2', () => { + usr.setTotalCoins(2); expect(usr.getTotalCoins()).toBe(2); }) it('should return 4', () => { + usr.setGamesPlayed(4); expect(usr.getGamesPlayed()).toBe(4); }) it('should return kikou', () => { - expect(usr.getCurrentSkin()).toBe(blue); + usr.setCurrentSkin(blue); + expect(usr.getCurrentSkin()).toEqual(blue); }) it('should return tab2', () => { - expect(usr.getTabSkin()).toBe(tab2); + usr.setTabSkin(tab2); + expect(usr.getTabSkin()).toEqual(tab2); }) }) \ No newline at end of file diff --git a/bob_party/src/services/conversationService/managerConversation.ts b/bob_party/src/services/conversationService/managerConversation.ts index 0e4758b..772627a 100644 --- a/bob_party/src/services/conversationService/managerConversation.ts +++ b/bob_party/src/services/conversationService/managerConversation.ts @@ -1,5 +1,4 @@ import { Conversation } from "../../core/conversation"; -import { User } from "../../core/User/user"; import ILoaderConversation from "./ILoaderConversation"; import ISaverConversation from "./ISaverConversation"; diff --git a/bob_party/src/services/tests/loaderUserApi.test.ts b/bob_party/src/services/tests/loaderUserApi.test.ts index 9d3c320..ef356d4 100644 --- a/bob_party/src/services/tests/loaderUserApi.test.ts +++ b/bob_party/src/services/tests/loaderUserApi.test.ts @@ -1,7 +1,7 @@ import LoaderUserApi from '../userServices/loaderUserApi'; import ILoaderUser from '../userServices/ILoaderUser'; -import { Match } from '../../core/match'; -import { MatchSolo } from '../../core/matchSolo'; +import { Match } from '../../core/Match/match'; +import MatchSolo from '../../core/Match/matchSolo'; import { GameSolo } from '../../core/gameSolo'; import tabUS from '../../constUser'; import { Conversation } from '../../core/conversation'; @@ -15,9 +15,9 @@ let map = new Map([ [100, 5], [150, 6] ]); -let game:GameSolo = new GameSolo('G0001', 'SuperJeu', img, 'source', 1, 1, map); -let match:Match = new MatchSolo('M0001', false, tabUS, game); -let convo:Conversation = new Conversation('C0001', tabUS, [], 'superConvo'); +let game:GameSolo = new GameSolo(1, 'SuperJeu', img, 'source', 1, 1, map); +let match:Match = new MatchSolo(1, false, tabUS, game); +let convo:Conversation = new Conversation(1, tabUS, [], 'superConvo'); // Tests @@ -31,10 +31,10 @@ describe('LoaderUserApi tests', () => { */ describe('loadById tests', () => { it('should return UserTest (id: 48)', () => { - expect(loader.loadByID('48')).toEqual(tabUS[0]); + expect(loader.loadByID(48)).toEqual(tabUS[0]); }) it('should return null', () => { - expect(loader.loadByID('jExistePas')).toBe(null); + expect(loader.loadByID(99999999999)).toBe(null); }) }) describe('loadByUserName tests', () => { diff --git a/bob_party/src/services/tests/stubUser.test.ts b/bob_party/src/services/tests/stubUser.test.ts index df32ffb..04295e0 100644 --- a/bob_party/src/services/tests/stubUser.test.ts +++ b/bob_party/src/services/tests/stubUser.test.ts @@ -2,8 +2,8 @@ import StubUser from '../userServices/stub'; import { User } from '../../core/User/user'; import { Skin } from '../../core/skin'; import { GameSolo } from '../../core/gameSolo'; -import { MatchSolo } from '../../core/matchSolo'; -import { Match } from '../../core/match'; +import MatchSolo from '../../core/Match/matchSolo'; +import { Match } from '../../core/Match/match'; import { Conversation } from '../../core/conversation'; // Instances @@ -16,14 +16,14 @@ let map = new Map([ [150, 6] ]); let tabUS:User[] = [ - new User("U0001", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob", img, 0), [new Skin("S0001", "Bob", img, 0)]), - new User("U0002", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob", img, 0), [new Skin("S0001", "Bob", img, 0)]), - new User("U0003", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0001", "Bob", img, 0), [new Skin("S0001", "Bob", img, 0)],), - new User("U0004", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob", img, 0), [new Skin("S0001", "Bob", img, 0)]), + new User(1, "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)]), + new User(2, "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)]), + new User(3, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)],), + new User(4, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)]), ]; -let game:GameSolo = new GameSolo('G0001', 'SuperJeu', img, 'source', 1, 1, map); -let match:Match = new MatchSolo('M0001', false, tabUS, game); -let convo:Conversation = new Conversation('C0001', tabUS, [], 'superConvo'); +let game:GameSolo = new GameSolo(1, 'SuperJeu', img, 'source', 1, 1, map); +let match:Match = new MatchSolo(1, false, tabUS, game); +let convo:Conversation = new Conversation(1, tabUS, [], 'superConvo'); // Tests @@ -35,10 +35,10 @@ describe('StubUser tests', () => { }) describe('loadById tests', () => { it('should return UserTest (id: 48)', () => { - expect(stub.loadByID('48')).toEqual(tabUS[0]); + expect(stub.loadByID(48)).toEqual(tabUS[0]); }) it('should return null', () => { - expect(stub.loadByID('jExistePas')).toBe(null); + expect(stub.loadByID(999999999999)).toBe(null); }) }) describe('loadByUserName tests', () => { diff --git a/bob_party/src/testGameSolo.ts b/bob_party/src/testGameSolo.ts index abee8d6..5121644 100644 --- a/bob_party/src/testGameSolo.ts +++ b/bob_party/src/testGameSolo.ts @@ -7,6 +7,6 @@ let myMap = new Map([ [150, 6] ]); -let game=new GameSolo("G0001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap); +let game=new GameSolo(1, "bo jeu", "", "super jeu", 1, 1, myMap); export default game; \ No newline at end of file