fix: remove rxjs (#376)
Some checks are pending
Continuous Delivery / Publishing Dev (push) Waiting to run
NPM / Publish / test-and-publish (push) Waiting to run

* firstcommit

* removerxjs

* document-task

* documentation+clean

* fixregres

* fix+regress

* fix+regres+errorhandling
This commit is contained in:
Jacob Nguyen
2025-01-13 10:33:53 -06:00
committed by GitHub
parent 7deb79e907
commit 59d08ef207
18 changed files with 970 additions and 906 deletions

View File

@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { Presence } from '../../src';
import * as Files from '../../src/core/module-loading'
import { presenceHandler } from '../../src/handlers/presence'
// Example test suite for the module function
describe('module function', () => {
@@ -54,4 +55,38 @@ describe('of function', () => {
activities: [{ name: 'Another Test Activity' }],
});
});
})
describe('Presence module execution', () => {
const mockExecuteResult = Presence.of({
status: 'online',
}).once();
const mockModule = Presence.module({
inject: [ '@sern/client'],
execute: vi.fn().mockReturnValue(mockExecuteResult)
})
beforeEach(() => {
vi.clearAllMocks();
// Mock Files.importModule
vi.spyOn(Files, 'importModule').mockResolvedValue({
module: mockModule
});
});
it('should set presence once.', async () => {
const setPresenceMock = vi.fn();
const mockPath = '/path/to/presence/config';
await presenceHandler(mockPath, setPresenceMock);
expect(Files.importModule).toHaveBeenCalledWith(mockPath);
expect(setPresenceMock).toHaveBeenCalledOnce();
})
})

View File

@@ -1,13 +1,11 @@
//@ts-nocheck
import { beforeEach, describe, expect, it, test } from 'vitest';
import { callInitPlugins, eventDispatcher } from '../src/handlers/event-utils';
import { callInitPlugins } from '../src/handlers/event-utils';
import { Client } from 'discord.js'
import { faker } from '@faker-js/faker';
import { Module } from '../src/types/core-modules';
import { Processed } from '../src/types/core-modules';
import { EventEmitter } from 'events';
import { CommandControlPlugin, CommandInitPlugin, CommandType, controller } from '../src';
import { CommandControlPlugin, CommandType, controller } from '../src';
import { createRandomModule, createRandomInitPlugin } from './setup/util';
@@ -19,23 +17,6 @@ function mockDeps() {
}
}
describe('eventDispatcher standard', () => {
let m: Processed<Module>;
let ee: EventEmitter;
beforeEach(() => {
ee = new EventEmitter();
m = createRandomModule();
});
it('should throw', () => {
expect(() => eventDispatcher(mockDeps(), m, 'not event emitter')).toThrowError();
});
it("Shouldn't throw", () => {
expect(() => eventDispatcher(mockDeps(), m, ee)).not.toThrowError();
});
});
describe('calling init plugins', async () => {
let deps;
beforeEach(() => {

View File

@@ -1,4 +1,6 @@
import { vi } from 'vitest'
import { makeDependencies } from '../../src';
import { Client } from 'discord.js';
vi.mock('discord.js', async (importOriginal) => {
const mod = await importOriginal()
@@ -44,3 +46,9 @@ vi.mock('discord.js', async (importOriginal) => {
ChatInputCommandInteraction: vi.fn()
};
});
await makeDependencies(({ add }) => {
add('@sern/client', { })
})