fixed set up for commands tests

This commit is contained in:
Aster Fialla
2026-02-24 15:57:33 -05:00
parent 5a91a529b1
commit 8b8cdd6d12

View File

@@ -28,7 +28,7 @@ jest.mock('console', () => {
return {error: jest.fn()} return {error: jest.fn()}
}) })
import {messageHelper, prefix} from "../src/helpers/messageHelper.js"; import {messageHelper} from "../src/helpers/messageHelper.js";
import {memberHelper} from "../src/helpers/memberHelper.js"; import {memberHelper} from "../src/helpers/memberHelper.js";
import {EmbedBuilder} from "@fluxerjs/core"; import {EmbedBuilder} from "@fluxerjs/core";
@@ -42,7 +42,14 @@ describe('commands', () => {
const username = 'somePerson' const username = 'somePerson'
const attachmentUrl = 'oya.json'; const attachmentUrl = 'oya.json';
const attachmentExpiration = new Date('2026-01-01').toDateString(); const attachmentExpiration = new Date('2026-01-01').toDateString();
const message = { let message;
const args = ['new']
beforeEach(() => {
jest.resetModules();
jest.clearAllMocks();
message= {
author: { author: {
username: username, username: username,
id: authorId, id: authorId,
@@ -50,20 +57,16 @@ describe('commands', () => {
}, },
attachments: { attachments: {
size: 1, size: 1,
first: jest.fn().mockImplementation(() => ({ first: jest.fn().mockImplementation(() => {
expires_at: attachmentExpiration, return {
url: attachmentUrl url: attachmentUrl,
})) expires_at: attachmentExpiration
}
})
}, },
reply: jest.fn().mockResolvedValue(), reply: jest.fn().mockResolvedValue(),
content: 'pf;import' content: 'pf;import'
} }
const args = ['new']
beforeEach(() => {
jest.resetModules();
jest.clearAllMocks();
}) })
describe('memberCommand', () => { describe('memberCommand', () => {
@@ -143,7 +146,7 @@ describe('commands', () => {
test('if attachment URL, call pluralKitImport with correct arguments', async () => { test('if attachment URL, call pluralKitImport with correct arguments', async () => {
// Arrange // Arrange
const args = [""]; const args = [""];
message.content = 'pf;import' message.content = 'pf;import';
importHelper.pluralKitImport = jest.fn().mockResolvedValue('success'); importHelper.pluralKitImport = jest.fn().mockResolvedValue('success');
// Act // Act
await commands.importCommand(message, args); await commands.importCommand(message, args);