ADD: new Neubaukompass provider | FIX: tests, console notifier

This commit is contained in:
Christian Kellner
2018-02-13 12:43:37 +01:00
parent 35bdc9e78c
commit 8a1d86c90e
14 changed files with 201 additions and 92 deletions

View File

@@ -26,19 +26,22 @@ describe('#einsAImmobilien testsuite()', () => {
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('einsAImmobilien');
/** check the actual structure **/
expect(notificationObj.payload.id).to.be.a('number');
expect(notificationObj.payload.price).to.be.a('string');
expect(notificationObj.payload.size).to.be.a('string');
expect(notificationObj.payload.title).to.be.a('string');
expect(notificationObj.payload.link).to.be.a('string');
notificationObj.payload.forEach((notify, idx) => {
/** check the values if possible **/
expect(notificationObj.payload.id).to.equal(immonetDbContent.einsAImmobilien[immonetDbContent.einsAImmobilien.length - 1]);
expect(notificationObj.payload.price).that.does.include('EUR');
expect(notificationObj.payload.size).that.does.include('m²');
expect(notificationObj.payload.title).to.be.not.empty;
expect(notificationObj.payload.link).that.does.include('https://www.1a-immobilienmarkt.de');
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');
expect(notify.link).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(immonetDbContent.einsAImmobilien[idx]);
expect(notify.price).that.does.include('EUR');
expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.1a-immobilienmarkt.de');
});
resolve();
});
});

View File

@@ -26,22 +26,24 @@ describe('#immonet testsuite()', () => {
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('immonet');
/** check the actual structure **/
expect(notificationObj.payload.id).to.be.a('number');
expect(notificationObj.payload.price).to.be.a('string');
expect(notificationObj.payload.size).to.be.a('string');
expect(notificationObj.payload.title).to.be.a('string');
expect(notificationObj.payload.link).to.be.a('string');
expect(notificationObj.payload.address).to.be.a('string');
/** check the values if possible **/
expect(notificationObj.payload.id).to.equal(immonetDbContent.immonet[immonetDbContent.immonet.length - 1]);
expect(notificationObj.payload.price).that.does.include('€');
expect(notificationObj.payload.size).that.does.include('m²');
expect(notificationObj.payload.title).to.be.not.empty;
expect(notificationObj.payload.link).that.does.include('https://www.immonet.de');
expect(notificationObj.payload.address).to.be.not.empty;
notificationObj.payload.forEach((notify, idx) => {
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');
expect(notify.link).to.be.a('string');
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(immonetDbContent.immonet[idx]);
expect(notify.price).that.does.include('€');
expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.immonet.de');
expect(notify.address).to.be.not.empty;
});
resolve();
});
});

View File

@@ -25,24 +25,26 @@ describe('#immoscout testsuite()', () => {
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('immoscout');
/** check the actual structure **/
expect(notificationObj.payload.id).to.be.a('number');
expect(notificationObj.payload.price).to.be.a('string');
expect(notificationObj.payload.size).to.be.a('string');
expect(notificationObj.payload.title).to.be.a('string');
expect(notificationObj.payload.link).to.be.a('string');
expect(notificationObj.payload.address).to.be.a('string');
/** check the values if possible **/
expect(notificationObj.payload.id).to.equal(
immoscoutDbContent.immoscout[immoscoutDbContent.immoscout.length - 1]
);
expect(notificationObj.payload.price).that.does.include('€');
expect(notificationObj.payload.size).that.does.include('m²');
expect(notificationObj.payload.title).to.be.not.empty;
expect(notificationObj.payload.link).that.does.include('https://www.immobilienscout24.de');
expect(notificationObj.payload.address).to.be.not.empty;
notificationObj.payload.forEach((notify, idx) => {
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');
expect(notify.link).to.be.a('string');
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(
immoscoutDbContent.immoscout[idx]
);
expect(notify.price).that.does.include('€');
expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.immobilienscout24.de');
expect(notify.address).to.be.not.empty;
});
resolve();
}).catch(resolve);
});

View File

@@ -26,24 +26,26 @@ describe('#immowelt testsuite()', () => {
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('immowelt');
/** check the actual structure **/
expect(notificationObj.payload.id).to.be.a('number');
expect(notificationObj.payload.price).to.be.a('string');
expect(notificationObj.payload.size).to.be.a('string');
expect(notificationObj.payload.title).to.be.a('string');
expect(notificationObj.payload.link).to.be.a('string');
expect(notificationObj.payload.address).to.be.a('string');
notificationObj.payload.forEach((notify, idx) => {
/** check the values if possible **/
expect(notificationObj.payload.id).to.equal(
immoweltDbContent.immowelt[immoweltDbContent.immowelt.length - 1]
);
expect(notificationObj.payload.price).that.does.include('€');
expect(notificationObj.payload.size).that.does.include('m²');
expect(notificationObj.payload.title).to.be.not.empty;
expect(notificationObj.payload.link).that.does.include('https://www.immowelt.de');
expect(notificationObj.payload.address).to.be.not.empty;
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');
expect(notify.link).to.be.a('string');
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(
immoweltDbContent.immowelt[idx]
);
expect(notify.price).that.does.include('€');
expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.immowelt.de');
expect(notify.address).to.be.not.empty;
});
resolve();
});
});

View File

@@ -27,20 +27,22 @@ describe('#kalaydo testsuite()', () => {
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('kalaydo');
/** check the actual structure **/
expect(notificationObj.payload.id).to.be.a('string');
expect(notificationObj.payload.price).to.be.a('string');
expect(notificationObj.payload.size).to.be.a('string');
expect(notificationObj.payload.title).to.be.a('string');
expect(notificationObj.payload.link).to.be.a('string');
notificationObj.payload.forEach((notify, idx) => {
/** check the values if possible **/
expect(notificationObj.payload.id).to.equal(kalaydoDbContent.kalaydo[kalaydoDbContent.kalaydo.length - 1]);
expect(notificationObj.payload.price).that.does.include('€');
expect(notificationObj.payload.size).that.does.include('m²');
expect(notificationObj.payload.title).to.be.not.empty;
expect(notificationObj.payload.link).that.does.include('https://www.kalaydo.de');
/** check the actual structure **/
expect(notify.id).to.be.a('string');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');
expect(notify.link).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(kalaydoDbContent.kalaydo[idx]);
expect(notify.price).that.does.include('€');
expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.kalaydo.de');
});
resolve();
});
});

View File

@@ -26,24 +26,26 @@ describe('#kleinanzeigen testsuite()', () => {
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('kleinanzeigen');
/** check the actual structure **/
expect(notificationObj.payload.id).to.be.a('number');
expect(notificationObj.payload.price).to.be.a('string');
expect(notificationObj.payload.size).to.be.a('string');
expect(notificationObj.payload.title).to.be.a('string');
expect(notificationObj.payload.link).to.be.a('string');
expect(notificationObj.payload.address).to.be.a('string');
notificationObj.payload.forEach((notify, idx) => {
/** check the values if possible **/
expect(notificationObj.payload.id).to.equal(
kleinanzeigenDbContent.kleinanzeigen[kleinanzeigenDbContent.kleinanzeigen.length - 1]
);
expect(notificationObj.payload.price).that.does.include('€');
expect(notificationObj.payload.size).that.does.include('m²');
expect(notificationObj.payload.title).to.be.not.empty;
expect(notificationObj.payload.link).that.does.include('https://www.ebay-kleinanzeigen.de');
expect(notificationObj.payload.address).to.be.not.empty;
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');
expect(notify.link).to.be.a('string');
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(
kleinanzeigenDbContent.kleinanzeigen[idx]
);
expect(notify.price).that.does.include('€');
expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.ebay-kleinanzeigen.de');
expect(notify.address).to.be.not.empty;
});
resolve();
});
});

View File

@@ -3,6 +3,7 @@ module.exports = {
send: (serviceName, payload) => {
this._tmpStore = { serviceName, payload };
return [Promise.resolve()];
},
get: () => {

View File

@@ -0,0 +1,50 @@
const mockNotification = require('./mocks/mockNotification');
const mockConfig = require('../conf/config.test');
const mockStore = require('./mocks/mockStore');
const mockStats = require('./mocks/mockStats');
const proxyquire = require('proxyquire').noCallThru();
const expect = require('chai').expect;
describe('#neubauKompass testsuite()', () => {
const neubauKompass = proxyquire('../lib/provider/neubauKompass', {
'../../conf/config.json': mockConfig,
'../lib/fredy': proxyquire('../lib/fredy', {
'./services/store': mockStore,
'./notification/notify': mockNotification
})
});
it('should test neubauKompass provider', async () => {
return await new Promise(resolve => {
neubauKompass.run(mockStats).then(() => {
const neubauKompassDbContent = neubauKompass._getStore()._db;
expect(neubauKompassDbContent.neubauKompass).to.be.a('array');
const notificationObj = mockNotification.get();
expect(notificationObj.serviceName).to.equal('neubauKompass');
notificationObj.payload.forEach((notify, idx) => {
expect(notify).to.be.a('object');
/** check the actual structure **/
expect(notify.id).to.be.a('string');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');
expect(notify.link).to.be.a('string');
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(neubauKompassDbContent.neubauKompass[idx]);
expect(notify.price).to.be.not.empty;
expect(notify.size).to.be.not.empty;
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.neubaukompass.de');
expect(notify.address).to.be.not.empty;
});
resolve();
});
});
});
});