diff --git a/bob_party/src/constUser.ts b/bob_party/src/constUser.ts index d4151f7..d7fb6c5 100644 --- a/bob_party/src/constUser.ts +++ b/bob_party/src/constUser.ts @@ -2,14 +2,14 @@ import { Message } from "./core/message" import { Conversation } from "./core/conversation" import tabSkinApp from './constSkin' import { User } from "./core/User/user"; -import tabConv from "./constCov"; -let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, []); -let UserTest:User=new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[2], tabSkinApp, []); -let Alban:User=new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, tabSkinApp[1], tabSkinApp, tabConv); -let Fefe63:User=new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], 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("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 tabUS:User[]=[UserActu, UserTest, Alban, Fefe63]; + +let tabUS:User[]=[UserTest, Alban, UserActu, Fefe63]; export default tabUS; \ No newline at end of file diff --git a/bob_party/src/services/tests/loaderUserApi.test.ts b/bob_party/src/services/tests/loaderUserApi.test.ts new file mode 100644 index 0000000..9cbfaec --- /dev/null +++ b/bob_party/src/services/tests/loaderUserApi.test.ts @@ -0,0 +1,50 @@ +import LoaderUserApi from '../userServices/loaderUserApi'; +import ILoaderUser from '../userServices/ILoaderUser'; +import { Match } from '../../core/match'; +import { MatchSolo } from '../../core/matchSolo'; +import { GameSolo } from '../../core/gameSolo'; +import tabUS from '../../constUser'; + +// Instances +let loader:ILoaderUser = new LoaderUserApi(); +let map = new Map([ + [50, 3], + [75, 4], + [100, 5], + [150, 6] +]); +let game:GameSolo = new GameSolo('G0001', 'SuperJeu', require('id'), 'source', 1, 1, map); +let match:Match = new MatchSolo('M0001', tabUS, game); + +// Tests +describe('LoaderUserApi tests', () => { + describe('loadById Tests', () => { + it('should return UserTest (id: 48)', () => { + expect(loader.loadByID('48')).toEqual(tabUS[0]); + }) + it('should return null', () => { + expect(loader.loadByID('jExistePas')).toBe(null); + }) + }) + describe('loadByUserName tests', () => { + it('should return USerTest (name: WeshWesh)', () => { + expect(loader.loadByUsername('WeshWesh')).toEqual(tabUS[0]); + }) + it('should return null', () => { + expect(loader.loadByUsername('jExistePas')).toBe(null); + }) + }) + describe('loadByUserNamePassword tests', () => { + it('should return UserTest (name: WeshWesh, password: MdpDeOuf)', () => { + expect(loader.loadByUsernamePassword('WeshWesh', 'MdpDeOuf')).toEqual(tabUS[0]); + }) + it('should return null', () => { + expect(loader.loadByUsernamePassword('jExistePas', 'jExistePas')).toBe(null); + }) + }) + describe('loadUserByMatch tests', () => { + it('should return UserTest', () => { + expect(loader.loadUserByMatch(match)).toEqual(tabUS[0]); + }) + }) +}) \ No newline at end of file diff --git a/bob_party/src/testGameSolo.ts b/bob_party/src/testGameSolo.ts index c8d6c14..abee8d6 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("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, myMap); +let game=new GameSolo("G0001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap); export default game; \ No newline at end of file