mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
fixing provider and their tests
This commit is contained in:
@@ -43,7 +43,9 @@ class Fredy {
|
|||||||
|
|
||||||
x((err, listings) => {
|
x((err, listings) => {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
else resolve(listings)
|
else {
|
||||||
|
resolve(listings);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ const Fredy = require('../fredy');
|
|||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
|
|
||||||
function normalize(o) {
|
function normalize(o) {
|
||||||
const size = `${o.size.replace(' Wohnfläche ', '').trim()} / ${o.rooms.trim()}`;
|
let size = `${o.size.replace(' Wohnfläche ', '').trim()}`;
|
||||||
|
if(o.rooms != null){
|
||||||
|
size+=` / / ${o.rooms.trim()}`;
|
||||||
|
}
|
||||||
const link = `https://www.1a-immobilienmarkt.de/expose/${o.id}.html`;
|
const link = `https://www.1a-immobilienmarkt.de/expose/${o.id}.html`;
|
||||||
|
|
||||||
return Object.assign(o, { size, link });
|
return Object.assign(o, { size, link });
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const immoscout = {
|
|||||||
size: '.result-list-entry .result-list-entry__criteria .grid-item:nth-child(2) dd | removeNewline | trim',
|
size: '.result-list-entry .result-list-entry__criteria .grid-item:nth-child(2) dd | removeNewline | trim',
|
||||||
title: '.result-list-entry .result-list-entry__brand-title-container h5 | removeNewline | trim',
|
title: '.result-list-entry .result-list-entry__brand-title-container h5 | removeNewline | trim',
|
||||||
link: '.result-list-entry .result-list-entry__brand-title-container@href',
|
link: '.result-list-entry .result-list-entry__brand-title-container@href',
|
||||||
address: '.result-list-entry .result-list-entry__address a'
|
address: '.result-list-entry .result-list-entry__map-link'
|
||||||
},
|
},
|
||||||
paginate: '#pager .align-right a@href',
|
paginate: '#pager .align-right a@href',
|
||||||
normalize: normalize,
|
normalize: normalize,
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ const neubauKompass = {
|
|||||||
crawlContainer: '.row article',
|
crawlContainer: '.row article',
|
||||||
crawlFields: {
|
crawlFields: {
|
||||||
id: '@id',
|
id: '@id',
|
||||||
title: 'div.p-2 > a@title | removeNewline | trim',
|
title: 'div.nbk-p-2 > h3 a@title | removeNewline | trim',
|
||||||
link: 'div.p-2 > a@href',
|
link: 'div.nbk-p-2 > h3 > a@href',
|
||||||
address: 'div.p-2 > p | removeNewline | trim'
|
address: 'div.nbk-p-2 > p | removeNewline | trim'
|
||||||
},
|
},
|
||||||
paginate: '.numbered-pager__bottom .numbered-pager--info li:nth-child(2) a@href',
|
paginate: '.numbered-pager__bottom .numbered-pager--info li:nth-child(2) a@href',
|
||||||
normalize: normalize,
|
normalize: normalize,
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ function applyBlacklist(o) {
|
|||||||
const titleNotBlacklisted = !utils.isOneOf(o.title, config.blacklist);
|
const titleNotBlacklisted = !utils.isOneOf(o.title, config.blacklist);
|
||||||
const descNotBlacklisted = !utils.isOneOf(o.description, config.blacklist);
|
const descNotBlacklisted = !utils.isOneOf(o.description, config.blacklist);
|
||||||
|
|
||||||
return titleNotBlacklisted && descNotBlacklisted;
|
|
||||||
|
return o.id != null && titleNotBlacklisted && descNotBlacklisted;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wgGesucht = {
|
const wgGesucht = {
|
||||||
@@ -20,9 +21,9 @@ const wgGesucht = {
|
|||||||
crawlContainer: '#main_column .panel:not(.display-none):not(.noprint)',
|
crawlContainer: '#main_column .panel:not(.display-none):not(.noprint)',
|
||||||
crawlFields: {
|
crawlFields: {
|
||||||
id: '@data-id',
|
id: '@data-id',
|
||||||
details: '.detail-size-price-wrapper .detailansicht |removeNewline |trim',
|
details: ' .list-details-costs-col |removeNewline |trim',
|
||||||
title: '.headline .detailansicht |removeNewline |trim',
|
title: '.headline .detailansicht |removeNewline |trim',
|
||||||
description: '.list-details-panel-inner p |removeNewline |trim',
|
description: '.list-details-category-location |removeNewline |trim',
|
||||||
link: '.headline .detailansicht@href'
|
link: '.headline .detailansicht@href'
|
||||||
},
|
},
|
||||||
paginate: '.pagination-sm:first a:last@href',
|
paginate: '.pagination-sm:first a:last@href',
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"format": "prettier --write lib/**/*.js test/**/*.js *.js --single-quote --print-width 120",
|
"format": "prettier --write lib/**/*.js test/**/*.js *.js --single-quote --print-width 120",
|
||||||
"test": "mocha --timeout 9000"
|
"test": "mocha --timeout 12000"
|
||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Christian Kellner",
|
"author": "Christian Kellner",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ describe('#einsAImmobilien testsuite()', () => {
|
|||||||
/** check the values if possible **/
|
/** check the values if possible **/
|
||||||
expect(notify.id).to.equal(immonetDbContent.einsAImmobilien[idx]);
|
expect(notify.id).to.equal(immonetDbContent.einsAImmobilien[idx]);
|
||||||
expect(notify.price).that.does.include('EUR');
|
expect(notify.price).that.does.include('EUR');
|
||||||
expect(notify.size).that.does.include('m²');
|
expect(notify.size).to.be.not.empty;
|
||||||
expect(notify.title).to.be.not.empty;
|
expect(notify.title).to.be.not.empty;
|
||||||
expect(notify.link).that.does.include('https://www.1a-immobilienmarkt.de');
|
expect(notify.link).that.does.include('https://www.1a-immobilienmarkt.de');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ describe('#immoscout testsuite()', () => {
|
|||||||
expect(notificationObj).to.be.a('object');
|
expect(notificationObj).to.be.a('object');
|
||||||
expect(notificationObj.serviceName).to.equal('immoscout');
|
expect(notificationObj.serviceName).to.equal('immoscout');
|
||||||
|
|
||||||
|
|
||||||
notificationObj.payload.forEach((notify, idx) => {
|
notificationObj.payload.forEach((notify, idx) => {
|
||||||
/** check the actual structure **/
|
/** check the actual structure **/
|
||||||
expect(notify.id).to.be.a('number');
|
expect(notify.id).to.be.a('number');
|
||||||
@@ -46,7 +45,7 @@ describe('#immoscout testsuite()', () => {
|
|||||||
expect(notify.address).to.be.not.empty;
|
expect(notify.address).to.be.not.empty;
|
||||||
});
|
});
|
||||||
resolve();
|
resolve();
|
||||||
}).catch(resolve);
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user