fixed entity map problems

This commit is contained in:
Mohammed Ashab Uddin
2020-07-28 10:44:40 +04:00
parent 595941341d
commit e71e9f372b
3 changed files with 19 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ class Entity {
addData(key ,value){
if(!this.isData(key)){
this.data[key] = value;
this.data.set(key, value);
return true;
}
return false;
@@ -20,12 +20,13 @@ class Entity {
* @param {string} key
*/
isData(key){
return this.data[key] != undefined ? true : false;
return this.data.has(key) ? true : false;
}
deleteData(key){
if(this.isData(key)){
return delete this.data[key];
this.data.delete(key);
return true;
}
return false;
}
@@ -37,7 +38,7 @@ class Entity {
getData(key){
if(this.isData(key)){
return this.data[key];
return this.data.get(key);
}
return null;
}

View File

@@ -91,7 +91,7 @@ describe('Command', () => {
});
it.only('Test : equals() with different message', () => {
it('Test : equals() with different message', () => {
let message = 'wg website web';

View File

@@ -52,4 +52,17 @@ describe('Entity', () => {
expect(a.getData('gada')).to.null;
})
it('Test: getAllData', () => {
let a = new Entity();
a.addData('hello world', new Website('hello world'));
a.addData('gada', new Website('gada'));
a.addData('pagol', new Website('pagol'));
let websitegen = a.getAllData().values();
for(let t of websitegen)
{
console.log(t.companyName);
}
})
})