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) => {
|
||||
if (err) reject(err);
|
||||
else resolve(listings)
|
||||
else {
|
||||
resolve(listings);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@ const Fredy = require('../fredy');
|
||||
const utils = require('../utils');
|
||||
|
||||
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`;
|
||||
|
||||
return Object.assign(o, { size, link });
|
||||
|
||||
@@ -14,21 +14,21 @@ function applyBlacklist(o) {
|
||||
}
|
||||
|
||||
const immoscout = {
|
||||
name: 'immoscout',
|
||||
enabled: config.sources.immoscout.enabled,
|
||||
url: config.sources.immoscout.url,
|
||||
name: 'immoscout',
|
||||
enabled: config.sources.immoscout.enabled,
|
||||
url: config.sources.immoscout.url,
|
||||
crawlContainer: '#resultListItems li.result-list__listing',
|
||||
crawlFields: {
|
||||
crawlFields: {
|
||||
id: '.result-list-entry@data-obid | int',
|
||||
price: '.result-list-entry .result-list-entry__criteria .grid-item:first-child 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',
|
||||
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',
|
||||
normalize: normalize,
|
||||
filter: applyBlacklist
|
||||
normalize: normalize,
|
||||
filter: applyBlacklist
|
||||
};
|
||||
|
||||
module.exports = new Fredy(immoscout);
|
||||
|
||||
@@ -17,9 +17,9 @@ const neubauKompass = {
|
||||
crawlContainer: '.row article',
|
||||
crawlFields: {
|
||||
id: '@id',
|
||||
title: 'div.p-2 > a@title | removeNewline | trim',
|
||||
link: 'div.p-2 > a@href',
|
||||
address: 'div.p-2 > p | removeNewline | trim'
|
||||
title: 'div.nbk-p-2 > h3 a@title | removeNewline | trim',
|
||||
link: 'div.nbk-p-2 > h3 > a@href',
|
||||
address: 'div.nbk-p-2 > p | removeNewline | trim'
|
||||
},
|
||||
paginate: '.numbered-pager__bottom .numbered-pager--info li:nth-child(2) a@href',
|
||||
normalize: normalize,
|
||||
|
||||
@@ -10,7 +10,8 @@ function applyBlacklist(o) {
|
||||
const titleNotBlacklisted = !utils.isOneOf(o.title, config.blacklist);
|
||||
const descNotBlacklisted = !utils.isOneOf(o.description, config.blacklist);
|
||||
|
||||
return titleNotBlacklisted && descNotBlacklisted;
|
||||
|
||||
return o.id != null && titleNotBlacklisted && descNotBlacklisted;
|
||||
}
|
||||
|
||||
const wgGesucht = {
|
||||
@@ -20,9 +21,9 @@ const wgGesucht = {
|
||||
crawlContainer: '#main_column .panel:not(.display-none):not(.noprint)',
|
||||
crawlFields: {
|
||||
id: '@data-id',
|
||||
details: '.detail-size-price-wrapper .detailansicht |removeNewline |trim',
|
||||
details: ' .list-details-costs-col |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'
|
||||
},
|
||||
paginate: '.pagination-sm:first a:last@href',
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"format": "prettier --write lib/**/*.js test/**/*.js *.js --single-quote --print-width 120",
|
||||
"test": "mocha --timeout 9000"
|
||||
"test": "mocha --timeout 12000"
|
||||
},
|
||||
"main": "index.js",
|
||||
"author": "Christian Kellner",
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('#einsAImmobilien testsuite()', () => {
|
||||
/** 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.size).to.be.not.empty;
|
||||
expect(notify.title).to.be.not.empty;
|
||||
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.serviceName).to.equal('immoscout');
|
||||
|
||||
|
||||
notificationObj.payload.forEach((notify, idx) => {
|
||||
/** check the actual structure **/
|
||||
expect(notify.id).to.be.a('number');
|
||||
@@ -46,7 +45,7 @@ describe('#immoscout testsuite()', () => {
|
||||
expect(notify.address).to.be.not.empty;
|
||||
});
|
||||
resolve();
|
||||
}).catch(resolve);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user