Ajout de test

Fix execution test
Quelques renames
This commit is contained in:
2021-01-30 14:02:59 +01:00
parent f1b1e23792
commit fa6f1abadb
7 changed files with 75 additions and 39 deletions

View File

@ -1,5 +1,3 @@
const YoutubeListenerRSSBuilder = require('./Models/YoutubeListenerRSSBuilder');
class ListenerBuildDirector {
_builder = undefined;
@ -9,7 +7,7 @@ class ListenerBuildDirector {
}
getListener() {
return this._builder.listenerRSS();
return this._builder.listenerRSS;
}
build(infos) {

View File

@ -1,4 +1,3 @@
const jsonFile = require('jsonfile');
const Parser = require('rss-parser');
@ -14,20 +13,29 @@ class ListenerRss {
loopRunning = false;
constructor(info) {
if(info !== undefined) {
this.setData(info);
this.setParser();
}
}
setParser() {
// set parser
this.parser = new Parser({
customFields : {
item: info._customfields.map((elt) => {
this.parser = new Parser(this.customfields !== undefined ? {
customFields: {
item: this.customfields.map((elt) => {
return Array.isArray(elt[1]) ? elt[1][0] : elt[1];
})
}
});
} : undefined); // if customfield is set -> let's set the parser with, else let the option empty
}
setData(infos) {
// Set data
this.name = info._name === undefined ? info._address : info._name; // if name is undefined let's take the address
this.address = info._address;
this.timeloop = info._timeloop;
this.customfields = info._customfields;
this.name = infos._name === undefined ? infos._address : infos._name; // if name is undefined let's take the address
this.address = infos._address;
this.timeloop = infos._timeloop;
this.customfields = infos._customfields;
}
fetchRSS() {

View File

@ -1,10 +1,10 @@
const ListenerRSS = require('../listener-rss');
const ListenerRSS = require('../../ListenerRss')
class AbstractListnerRSSBuilder {
class AbstractListenerRSSBuilder {
_listenerRSS = undefined;
constructor() {
if(this.constructor === AbstractListnerRSSBuilder)
if(this.constructor === AbstractListenerRSSBuilder)
throw new Error('The Abstract class "AbstractListnerRSSBuilder" cannot be instantiated');
}
@ -17,6 +17,7 @@ class AbstractListnerRSSBuilder {
this.setInfos(infos);
this.setSpecificInfos();
this.listenerRSS.setParser()
}
/**
@ -31,10 +32,7 @@ class AbstractListnerRSSBuilder {
}
setInfos(infos) { // Nominal Infos (like name, addresse, and other)
this._listenerRSS.name = infos._name;
this._listenerRSS.address = infos._address;
this._listenerRSS.timeloop = infos._timeloop;
this._listenerRSS.name = infos._name;
this._listenerRSS.setData(infos);
}
setSpecificInfos() { // More generic infos who's depend of platforms
@ -44,4 +42,4 @@ class AbstractListnerRSSBuilder {
}
module.exports = AbstractListnerRSSBuilder
module.exports = AbstractListenerRSSBuilder

View File

@ -1,4 +1,4 @@
const AbstractListenerRSSBuilder = require('AbstractListenerRSSBuilder')
const AbstractListenerRSSBuilder = require('./AbstractListenerRSSBuilder');
class YoutubeListenerRSSBuilder extends AbstractListenerRSSBuilder {
constructor() {
@ -6,7 +6,7 @@ class YoutubeListenerRSSBuilder extends AbstractListenerRSSBuilder {
}
setSpecificInfos() {
this.listenerRSS._customfields = [
this.listenerRSS.customfields = [
['description', ['media:group', 'media:description']],
['icon', ['media:group', 'media:thumbnail']]
]

View File

@ -39,4 +39,4 @@ class ListenerRSSInfos {
}
}
module.exports = ListenerRSSInfos
module.exports = ListenerRSSInfos;