diff --git a/whatsapp-web.js/src/models/entity.js b/whatsapp-web.js/src/models/entity.js index 8297cb3..0bcce8f 100644 --- a/whatsapp-web.js/src/models/entity.js +++ b/whatsapp-web.js/src/models/entity.js @@ -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; } diff --git a/whatsapp-web.js/test/test_command.js b/whatsapp-web.js/test/test_command.js index b0786b7..fff3df5 100644 --- a/whatsapp-web.js/test/test_command.js +++ b/whatsapp-web.js/test/test_command.js @@ -91,7 +91,7 @@ describe('Command', () => { }); - it.only('Test : equals() with different message', () => { + it('Test : equals() with different message', () => { let message = 'wg website web'; diff --git a/whatsapp-web.js/test/test_entity.js b/whatsapp-web.js/test/test_entity.js index f42eb2e..56a3e22 100644 --- a/whatsapp-web.js/test/test_entity.js +++ b/whatsapp-web.js/test/test_entity.js @@ -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); + } + }) + }) \ No newline at end of file