forked from Outils-PeerTube/listener-rss-aggregator
		
	added test's setup
This commit is contained in:
		
							
								
								
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -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",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								package.json
									
									
									
									
									
								
							@@ -11,13 +11,13 @@
 | 
			
		||||
  "author": "Amaury Joly <amaury.joly@hotmail.com>",
 | 
			
		||||
  "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": {
 | 
			
		||||
 
 | 
			
		||||
@@ -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));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										40
									
								
								test/index-spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								test/index-spec.ts
									
									
									
									
									
										Normal file
									
								
							@@ -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,
 | 
			
		||||
    },
 | 
			
		||||
  ];
 | 
			
		||||
});
 | 
			
		||||
		Reference in New Issue
	
	Block a user