cleanup tests, codegen, and importing handler

This commit is contained in:
jacob
2024-05-02 17:27:57 -05:00
parent d3245c8a0c
commit d7ebdb2edc
10 changed files with 30 additions and 103 deletions

View File

@@ -1,6 +1,6 @@
import { assertType, describe, it } from 'vitest';
import { __Services } from '../../src/core/structures';
import * as __Services from '../../src/core/structures/default-services';
import * as Contracts from '../../src/core/interfaces';
describe('default contracts', () => {

View File

@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import { CoreContainer } from '../../src/core/ioc/container';
import { EventEmitter } from 'events';
import { Disposable, Emitter, Init, Logging } from '../../src/core/interfaces';
import { __Services } from '../../src/core/structures'
import * as __Services from '../../src/core/structures/default-services'
import { CoreDependencies } from '../../src/types/ioc';
describe('ioc container', () => {

View File

@@ -5,7 +5,7 @@ import { Presence } from '../../src';
// Example test suite for the module function
describe('module function', () => {
it('should return a valid configuration', () => {
const config: Presence.Config<['dependency1', 'dependency2']> = Presence.module({
const config = Presence.module({
inject: ['dependency1', 'dependency2'],
execute: vi.fn(),
});

View File

@@ -1,6 +1,6 @@
import { SpyInstance, afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { CoreContainer } from '../../src/core/ioc/container';
import { __Services } from '../../src/core/structures/';
import * as __Services from '../../src/core/structures/default-services';
import { faker } from '@faker-js/faker';
import { commandModule, CommandType } from '../../src';

View File

@@ -1,8 +1,8 @@
import { beforeEach, describe, expect, vi, it } from 'vitest';
import { eventDispatcher } from '../../src/handlers/dispatchers';
import { eventDispatcher } from '../../src/handlers/event-utils';
import { faker } from '@faker-js/faker';
import { Module } from '../../src/types/core-modules';
import { Processed } from '../../src/handlers/types';
import { Processed } from '../../src/types/core-modules';
import { CommandType } from '../../src/core/structures/enums';
import { EventEmitter } from 'events';

View File

@@ -1,47 +0,0 @@
import { describe, expect, it, vi } from 'vitest';
import * as Id from '../../src/core/id';
import { faker } from '@faker-js/faker';
import { CommandModule, CommandType, commandModule } from '../../src';
function createRandomCommandModules() {
const randomCommandType = [
CommandType.Text,
CommandType.Both,
CommandType.CtxMsg,
CommandType.CtxUser,
CommandType.Modal,
CommandType.ChannelSelect,
CommandType.RoleSelect,
CommandType.UserSelect,
CommandType.StringSelect,
CommandType.Button,
];
return commandModule({
type: faker.helpers.uniqueArray(randomCommandType, 1)[0],
description: faker.string.alpha(),
name: faker.string.alpha(),
execute: () => {},
});
}
function createMetadata(c: CommandModule) {
return {
fullPath: faker.system.filePath(),
id: Id.create(c.name, c.type),
isClass: Boolean(Math.floor(Math.random())),
};
}
const appBitField = 0b000000001111;
describe('id resolution', () => {
it('should resolve application commands correctly', () => {
const modules = faker.helpers.multiple(createRandomCommandModules, {
count: 20,
});
const metadata = modules.map(createMetadata);
metadata.forEach((meta, idx) => {
const associatedModule = modules[idx];
const uid = Id.create(associatedModule.name!, associatedModule.type!);
expect(meta.id).toBe(uid);
});
});
});