add first passing test
This commit is contained in:
parent
f41194ba71
commit
c39f9c6ee1
28
tests/helpers/memberRoles.test.ts
Normal file
28
tests/helpers/memberRoles.test.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Collection, GuildMember, Role } from "discord.js"
|
||||
import { filterRolesFromMemberUpdate } from "../../server/helper/roleFilter"
|
||||
|
||||
function buildFakeRole(id: string, name: string): Role {
|
||||
return <Role>{ id, name }
|
||||
|
||||
}
|
||||
test('filterRolesFromMemberUpdate', () => {
|
||||
const oldMemberRoles: Collection<string, Role> = new Collection<string, Role>()
|
||||
oldMemberRoles.set('1', buildFakeRole('01', 'Role01'))
|
||||
oldMemberRoles.set('2', buildFakeRole('02', 'Role02'))
|
||||
|
||||
const newMemberRoles: Collection<string, Role> = new Collection<string, Role>()
|
||||
newMemberRoles.set('1', buildFakeRole('01', 'Role01'))
|
||||
newMemberRoles.set('2', buildFakeRole('02', 'Role02'))
|
||||
newMemberRoles.set('3', buildFakeRole('03', 'Role03'))
|
||||
|
||||
const oldMember: GuildMember = <GuildMember>{ roles: { cache: oldMemberRoles }, guild: { id: "guildid" } }
|
||||
const newMember: GuildMember = <GuildMember>{ roles: { cache: newMemberRoles }, guild: { id: "guildid" } }
|
||||
const output = filterRolesFromMemberUpdate(oldMember, newMember)
|
||||
|
||||
const expectedAddedRoles: Collection<string, Role> = new Collection<string, Role>()
|
||||
expectedAddedRoles.set('3', buildFakeRole('03', 'Role03'))
|
||||
const expectedRemovedRoles: Collection<string, Role> = new Collection<string, Role>()
|
||||
|
||||
expect(output.addedRoles).toEqual(expectedAddedRoles)
|
||||
expect(output.removedRoles).toEqual(expectedRemovedRoles)
|
||||
})
|
Loading…
Reference in New Issue
Block a user