Files
Custom-Static-Website-Gener…/whatsapp-web.js/test/test_entity.js
Mohammed Ashab Uddin 3bb0dbd2a4 accepts message with ""
2020-08-03 10:54:48 +04:00

117 lines
3.5 KiB
JavaScript

const expect = require('chai').expect;
const {data} = require('../src/models/data')
const {Entity} = require('../src/models/entity');
const { Website } = require('../src/models/website');
describe('Entity', () => {
it('Test : addData', () => {
let a = new Entity();
a.addData('hello', new Website('hello'));
expect(a.isData('hello')).to.true;
expect(a.count).to.equal(0);
});
it('Test : clearData()', () => {
let a = new Entity();
a.addData('hello world', new Website('hello world'));
a.addData('gada', new Website('gada'));
a.addData('pagol', new Website('pagol'));
a.clearData();
expect(a.count).to.equal(0);
expect(a.isData("kruta")).to.false;
expect(a.isData("hello")).to.false;
expect(a.isData('pagol')).to.false;
expect(a.isData('hello world')).to.false;
});
it('Test: getData', () => {
let a = new Entity();
a.addData('hello world', new Website('hello world'));
a.addData('gada', new Website('gada'));
a.addData('pagol', new Website('pagol'));
expect(a.getData('hello world').companyName).to.equal('hello world');
expect(a.getData('gada').companyName).to.equal('gada');
expect(a.getData('chu chu')).to.null;
})
it('Test: deleteData', () => {
let a = new Entity();
a.addData('hello world', new Website('hello world'));
a.addData('gada', new Website('gada'));
a.addData('pagol', new Website('pagol'));
a.deleteData('gada');
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);
}
})
it('Test: selectData()', () => {
let a = new Entity();
a.addData('hello world', new Website('hello world'));
a.addData('gada', new Website('gada'));
a.addData('pagol', new Website('pagol'));
a.selectData('gada');
expect(a.selectedData).to.equals('gada');
});
it('Test: selectedData() = false', () => {
let a = new Entity();
a.addData('hello world', new Website('hello world'));
a.addData('gada', new Website('gada'));
a.addData('pagol', new Website('pagol'));
a.selectData('tara');
expect(a.selectedData).to.equals('pagol');
});
it('Test: selectedData when addData() is used', () => {
let a = new Entity();
a.addData('hello world', new Website('hello world'));
a.addData('gada', new Website('gada'));
a.addData('pagol', new Website('pagol'));
expect(a.selectedData).to.equals('pagol');
});
it('Test : selectedData when clearData()', () => {
let a = new Entity();
a.addData('hello world', new Website('hello world'));
a.addData('gada', new Website('gada'));
a.addData('pagol', new Website('pagol'));
a.clearData();
expect(a.count).to.equal(0);
expect(a.isData("kruta")).to.false;
expect(a.isData("hello")).to.false;
expect(a.isData('pagol')).to.false;
expect(a.isData('hello world')).to.false;
expect(a.selectedData).to.null;
});
})