routing/tests/discord-spec.ts

56 lines
1.7 KiB
TypeScript
Raw Normal View History

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<Client>,
channelManagerStub: sinon.SinonStubbedInstance<ChannelManager>;
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");
});
});