fixed entity map problems
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ describe('Command', () => {
|
||||
|
||||
});
|
||||
|
||||
it.only('Test : equals() with different message', () => {
|
||||
it('Test : equals() with different message', () => {
|
||||
|
||||
let message = 'wg website web';
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user