UNPKG

dbots

Version:

Discord bot list poster and stats retriever

66 lines (56 loc) 2.01 kB
import * as ClientFillerModule from '../../src/Interface/ClientFiller' describe('ClientFiller module', () => { const { ClientFiller, getClientFiller } = ClientFillerModule describe('ClientFiller class', () => { let cf: ClientFillerModule.ClientFiller const customClient = { a: 'a', b: 'b' } it('should reject non-object clients', () => { expect(() => { // @ts-expect-error new ClientFiller('a') }).toThrow() expect(() => { // @ts-expect-error new ClientFiller(true) }).toThrow() expect(() => { // @ts-expect-error new ClientFiller(Symbol()) }).toThrow() }) it('should instantiate with a valid client', () => { expect(() => { cf = new ClientFiller(customClient) }).not.toThrow() }) it('should correctly set the client', () => { expect(cf.client).toBe(customClient) }) it('should only have placeholder properties', () => { expect(cf.userCount).toBe(0) expect(cf.serverCount).toBe(0) expect(cf.voiceConnections).toBe(0) expect(cf.clientID).toBeUndefined() expect(cf.shard).toBeUndefined() }) }) describe('getClientFiller function', () => { it('should throw without any client', () => { // @ts-expect-error expect(() => getClientFiller('')).toThrow() }) it('should throw without a valid library name', () => { expect(() => { // @ts-expect-error getClientFiller('invalid', {}) }).toThrow() }) it('should return a ClientFiller for every supported library', () => { expect(getClientFiller('discordie', {})).toBeInstanceOf(ClientFiller) expect(getClientFiller('discord.io', {})).toBeInstanceOf(ClientFiller) expect(getClientFiller('discord.js', {})).toBeInstanceOf(ClientFiller) expect(getClientFiller('eris', {})).toBeInstanceOf(ClientFiller) expect(getClientFiller('paracord', {})).toBeInstanceOf(ClientFiller) }) }) })