Skip to content

Commit

Permalink
isAdmin: add tsests
Browse files Browse the repository at this point in the history
  • Loading branch information
Asartea committed Jul 14, 2024
1 parent 0c07da9 commit a1f834f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions utils/is-admin.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { Member } = require('discord.js');
const { Collection } = require('@discordjs/collection');
const { isAdmin } = require('./is-admin'); // Adjust the path as necessary

jest.mock('discord.js', () => ({
Member: jest.fn().mockImplementation((roles) => ({
roles: {
cache: roles,
},
})),
}));

describe('isAdmin', () => {
it('should return true if the user has an admin role', () => {
const memberMap = new Collection();
memberMap.set('role-1', { name: 'core' });
const member = Member(memberMap);
expect(isAdmin(member)).toBe(true);
});

it('should return false if the user does not have an admin role', () => {
const memberMap = new Collection();
const member = Member(memberMap);
expect(isAdmin(member)).toBe(false);
});
});

0 comments on commit a1f834f

Please sign in to comment.