import chai from 'chai'; import sinon from 'ts-sinon'; import sinonChai from 'sinon-chai'; chai.use(sinonChai); const expect = chai.expect; import nock, { disableNetConnect, RequestBodyMatcher } from 'nock'; import { DiscordParser } from '../src/discordParser'; //data const config: DiscordParser.Config = { channelsId: { idChannelPeerTube: 'peertubeID', idChannelYtb: 'ytbChannel', }, keyWord: 'myDiscordKeyword', name: 'DiscordTestedInterface', token: 'mySecretDiscordToken', }; //stubed imports import { Channel, ChannelManager, Client } from 'discord.js'; import { utils } from 'mocha'; describe.only('test DiscordParser', function () { let clientStub: sinon.SinonStubbedInstance, channelManagerStub: sinon.SinonStubbedInstance; before(() => { clientStub = sinon.createStubInstance(Client); clientStub.login.withArgs(config.token).onFirstCall().resolves('ok'); clientStub.login.throws('Error, bad parameter or too much call'); channelManagerStub = sinon.createStubInstance(ChannelManager); channelManagerStub.resolve .withArgs(config.channelsId.idChannelPeerTube) .onFirstCall() .returns(new Channel(new Client())) .withArgs(config.channelsId.idChannelYtb) .onFirstCall() .returns(new Channel(new Client())); channelManagerStub.resolve.throws("Error Bad id's or too much call"); }); after(() => { clientStub.login.restore(); channelManagerStub.resolve.restore(); }); it('it will test the DiscordParser constructor', function () { const discordParser = new DiscordParser(config); console.log("c'est bon signe"); }); });