suite tests unitaires

Persistance
Mathilde JEAN 2 years ago
parent a57606dcbd
commit 03e24e0514

@ -4,6 +4,7 @@ import { Match } from '../../core/match';
import { MatchSolo } from '../../core/matchSolo'; import { MatchSolo } from '../../core/matchSolo';
import { GameSolo } from '../../core/gameSolo'; import { GameSolo } from '../../core/gameSolo';
import tabUS from '../../constUser'; import tabUS from '../../constUser';
import { Conversation } from '../../core/conversation';
// Instances // Instances
let loader:ILoaderUser = new LoaderUserApi(); let loader:ILoaderUser = new LoaderUserApi();
@ -15,10 +16,19 @@ let map = new Map<number, number>([
]); ]);
let game:GameSolo = new GameSolo('G0001', 'SuperJeu', require('id'), 'source', 1, 1, map); let game:GameSolo = new GameSolo('G0001', 'SuperJeu', require('id'), 'source', 1, 1, map);
let match:Match = new MatchSolo('M0001', tabUS, game); let match:Match = new MatchSolo('M0001', tabUS, game);
let convo:Conversation = new Conversation(tabUS, [], 'superConvo');
// Tests // Tests
describe('LoaderUserApi tests', () => { describe('LoaderUserApi tests', () => {
describe('loadById Tests', () => { /*
describe('loadAllUser tests', () => {
it('should return tabUS [UserTest, Alban, UserActu, Fefe63]', () => {
expect(loader.loadAllUser()).toEqual(tabUS);
})
})
*/
describe('loadById tests', () => {
it('should return UserTest (id: 48)', () => { it('should return UserTest (id: 48)', () => {
expect(loader.loadByID('48')).toEqual(tabUS[0]); expect(loader.loadByID('48')).toEqual(tabUS[0]);
}) })
@ -46,5 +56,20 @@ describe('LoaderUserApi tests', () => {
it('should return UserTest', () => { it('should return UserTest', () => {
expect(loader.loadUserByMatch(match)).toEqual(tabUS[0]); expect(loader.loadUserByMatch(match)).toEqual(tabUS[0]);
}) })
it('should return null', () => {
expect(loader.loadByUsernamePassword('jExistePas', 'jExistePas')).toEqual(null);
})
})
describe('loadUserByConversation tests', () => {
it('should return tabUS', () => {
expect(loader.loadUserByConversation(convo)).toEqual(tabUS);
})
})
/*
describe('loadLastId', () => {
it('should return U0004', () => {
expect(loader.loadLastId()).toBe('U0004');
})
}) })
*/
}) })

@ -0,0 +1,22 @@
import StubUser from '../userServices/stub';
import { User } from '../../core/User/user';
import { Skin } from '../../core/skin';
// Instances
let stub:StubUser = new StubUser();
let tabUS:User[] = [
new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)],),
new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
];
// Tests
describe('StubUser tests', () => {
describe('loadAllUser tests', () => {
it('should return tabUS', () => {
expect(stub.loadAllUser()).toEqual(tabUS);
})
})
})

@ -6,7 +6,7 @@ import ILoaderUser from "./ILoaderUser";
export default class StubUser implements ILoaderUser{ export default class StubUser implements ILoaderUser{
tabUS:User[]=[ private tabUS:User[]=[
new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]), new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]), new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)],), new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)],),

Loading…
Cancel
Save