1
+ import Collection from '@discordjs/collection'
1
2
import * as PosterModule from '../../src/Interface/Poster'
2
3
import { Service } from '../../src/Interface/Service'
3
4
import TopGG from '../../src/Interface/Lists/TopGG'
@@ -6,6 +7,11 @@ import { PosterOptions } from '../../src/Utils/Constants'
6
7
describe ( 'Poster module' , ( ) => {
7
8
describe ( 'Poster class' , ( ) => {
8
9
const { Poster } = PosterModule
10
+ const fakeClientGuilds = new Collection (
11
+ Array ( 123 )
12
+ . fill ( 'a' )
13
+ . map ( ( _value , index ) => [ index , { memberCount : 2 } ] ) as [ number , any ] [ ]
14
+ )
9
15
10
16
describe ( 'constructor' , ( ) => {
11
17
it ( 'should throw when instatiated without options' , ( ) => {
@@ -109,12 +115,17 @@ describe('Poster module', () => {
109
115
expect ( fn ) . toHaveBeenCalled ( )
110
116
} )
111
117
112
- it ( 'should use the clientFiller' , ( ) => {
118
+ it ( 'should use the clientFiller' , ( done ) => {
113
119
const p = new Poster ( {
114
- client : { users : { size : 123 } } ,
120
+ client : { guilds : fakeClientGuilds } ,
115
121
clientLibrary : 'discord.js'
116
122
} )
117
- expect ( p . getUserCount ( ) ) . resolves . toBe ( 123 )
123
+ p . getUserCount ( )
124
+ . then ( ( res ) => {
125
+ expect ( res ) . toBe ( 123 * 2 )
126
+ done ( )
127
+ } )
128
+ . catch ( ( ) => done . fail ( ) )
118
129
} )
119
130
120
131
it ( 'should default to 0' , ( ) => {
@@ -219,7 +230,7 @@ describe('Poster module', () => {
219
230
describe ( 'post method' , ( ) => {
220
231
const p = new Poster ( {
221
232
client : {
222
- guilds : { size : 123 } ,
233
+ guilds : fakeClientGuilds ,
223
234
users : { size : 456 } ,
224
235
broadcasts : { size : 789 }
225
236
} ,
@@ -242,7 +253,7 @@ describe('Poster module', () => {
242
253
await p . post ( 'service' )
243
254
expect ( p . postManual ) . toHaveBeenLastCalledWith ( 'service' , {
244
255
serverCount : 123 ,
245
- userCount : 456 ,
256
+ userCount : 123 * 2 ,
246
257
voiceConnections : 789
247
258
} )
248
259
} )
0 commit comments