corrections classes et unit tests
continuous-integration/drone/push Build is passing Details

ajout id sur Conversation et Message
typescript^2^2
Mathilde JEAN 2 years ago
parent 721daf994f
commit 82f97da82b

@ -3,12 +3,14 @@ import { User } from "./User/user";
export class Conversation{
private Id: string;
private tabUser: User[];
private tabMessage: Message[];
private name: string;
/* Constructor of the class */
constructor(tabUser: User[], tabMessage:Message[], name:string){
constructor(id: string, tabUser: User[], tabMessage:Message[], name:string){
this.Id=id;
this.tabUser=[...tabUser];
this.tabMessage=[...tabMessage];
this.name=name;
@ -36,6 +38,11 @@ export class Conversation{
this.sortMessageDesc();
}
/* Brief : function returning the id of a conversation */
getId(){
return this.Id;
}
/* Brief : function returning the name to a conversation */
getName(){
return this.name;

@ -2,12 +2,14 @@ import { User } from './User/user'
export class Message{
private Id: string;
private Content: string;
private Sender: User;
private DateEnvoie: Date;
/* Constructor of the class */
constructor(content: string, sender:User, dateEnvoie:Date){
constructor(id: string, content: string, sender:User, dateEnvoie:Date){
this.Id=id;
this.Content=content;
this.Sender=sender;
this.DateEnvoie=dateEnvoie;
@ -28,6 +30,11 @@ export class Message{
this.DateEnvoie=dateEnvoie;
}
/* Brief : Function getting the id of a message */
getMessageId(){
return this.Id;
}
/* Brief : Function getting the content of a message */
getMessageContent(){
return this.Content;

@ -15,26 +15,29 @@ let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8
let theDate = new Date(2022,10,14);
let theDate2 = new Date(2022,10,13);
let theDate3 = new Date(2022,10,15);
let mess = new Message('Bob Party est le meilleur projet', usr, theDate2);
let mess = new Message('M0001', 'Bob Party est le meilleur projet', usr, theDate2);
let tabU:User[] = [usr, usr2];
let mess2 = new Message('Oui tout à fait', usr2, theDate);
let mess3 = new Message('Mais oui trop de ouf', usr, theDate3);
let mess2 = new Message('M0002', 'Oui tout à fait', usr2, theDate);
let mess3 = new Message('M0003', 'Mais oui trop de ouf', usr, theDate3);
let tabM:Message[] = [mess, mess2];
let convo = new Conversation(tabU, tabM, 'the conv');
let convo = new Conversation('C0001', tabU, tabM, 'the conv');
let usr3 = new User('00003', '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 the conv', () => {
expect(convo.getName()).toBe('the conv');
})
it('should return tabU [usr, usr2] (users)', () => {
expect(convo.getTabUser()).toBe(tabU);
})
it('should return tabM [mess, mess2] (messages)', () => {
expect(convo.getTabMessage()).toBe(tabM);
})
it('should return the conv', () => {
expect(convo.getName()).toBe('the conv');
})
it('should return Oui tout à fait (mess2)', () => {
expect(convo.getLastMessage()).toBe('Oui tout à fait');
})

@ -12,11 +12,14 @@ let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0,
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);
let mess = new Message('M0001', '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 Bob Party est le meilleur projet', () => {
expect(mess.getMessageContent()).toBe('Bob Party est le meilleur projet');
})

Loading…
Cancel
Save