diff --git a/package-lock.json b/package-lock.json index ad42504..d88cd71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2475,6 +2475,12 @@ "is-number": "^7.0.0" } }, + "ts-mock-imports": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/ts-mock-imports/-/ts-mock-imports-1.3.3.tgz", + "integrity": "sha512-zCAcb89Y+f3Bhw5VaHrHMh5tiuwAQEl5D3e0r5ELCdLl9EnZpb8Oeei/S60Qf4LORIfmJEXb3TpR5kxtL6j2cg==", + "dev": true + }, "ts-node": { "version": "9.1.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", diff --git a/package.json b/package.json index c182597..f3c3e84 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ "author": "Amaury Joly ", "license": "MIT", "devDependencies": { - "@types/node": "^14.14.33", - "@types/mocha": "^8.2.1", "@types/chai": "^4.2.15", - "@typescript-eslint/parser": "^4.17.0", + "@types/mocha": "^8.2.1", + "@types/node": "^14.14.33", "@typescript-eslint/eslint-plugin": "^4.17.0", - "cross-env": "^7.0.3", + "@typescript-eslint/parser": "^4.17.0", "chai": "^4.3.3", + "cross-env": "^7.0.3", "eslint": "^7.21.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-config-prettier": "^8.1.0", @@ -26,9 +26,10 @@ "eslint-plugin-prettier": "3.3.1", "mocha": "8.2.1", "prettier": "2.2.1", - "sinon-chai": "3.5.0", - "ts-sinon": "2.0.1", + "sinon-chai": "^3.5.0", + "ts-mock-imports": "^1.3.3", "ts-node": "9.1.1", + "ts-sinon": "2.0.1", "typescript": "^4.1.3" }, "dependencies": { diff --git a/src/gestion-listener.ts b/src/gestion-listener.ts index 8ac1b17..a7859ff 100644 --- a/src/gestion-listener.ts +++ b/src/gestion-listener.ts @@ -1,5 +1,19 @@ -import {} from ""; +import { ListenerRss, ListenerRSSInfos } from "listener-rss/src/"; +/** + * Permit to manage a ListenerRSS array, data storage and event aggregation + */ export class GestionListener { - GestionListener(): any {} + listenerArray: ListenerRss[] = []; + + GestionListener(path?: string): void { + if (path) { + // load a file or a bdd + } else { + // keep the class empty + } + } + addNewListener(info: ListenerRSSInfos): void { + this.listenerArray.concat(new ListenerRss(info)); + } } diff --git a/test/index-spec.ts b/test/index-spec.ts new file mode 100644 index 0000000..8172b54 --- /dev/null +++ b/test/index-spec.ts @@ -0,0 +1,40 @@ +// external lib +import { ListenerRss, ListenerRSSInfos } from "listener-rss/src/"; + +// local lib +import { GestionListener } from "/src/index"; + +// Unit test +import * as chai from "chai"; +import sinon from "ts-sinon"; +import sinonChai from "sinon-chai"; +import { ImportMock, InPlaceMockManager } from "ts-mock-imports"; + +chai.use(sinonChai); + +const expect = chai.expect; + +describe("test class GestionListener", function () { + const listenerInfoArray: ListenerRSSInfos[] = [ + { + name: "service1", + address: "fake.rss.service1", + timeloop: 45, + }, + { + name: "service2", + address: "fake.rss.service2", + timeloop: 30, + }, + { + name: "service3", + address: "fake.rss.service3", + timeloop: 15, + }, + { + name: "service4", + address: "fake.rss.service4", + timeloop: 60, + }, + ]; +});