mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
* step 1 * Refactorings * command modules do not depend on anything but itself * tearing it up * Remove module store, manager, and Intializable type * consolidate interfaces in single file * consolidate default services in single file * TEAR IT UP * fix text compile * the end of sern init?? * Presence namespaced types removed * internal namespace * clean up dependencies * fix test * fix circular dependency * still broken but progress * remove barrel for core/structs * reffactor * refactor allat * more refactoring * prototyping linking static handler * cleanup tests, codegen, and importing handler * some refactor * generify partition * for now copy paste new ioc system * removeiti * fdsfD * ensure container is init'd * fix absPath gen * working on bun compat * refactor and clean up and reenter v3 module loading * dsfsd * refactor, add cron types, reinstante module loader * ready handler revamped so much cleaner * fdssdf * refactor deps list * add more tests, polish up ioc * up to speed with event modules * i think cron works * cron works now, poc * ksdjkldsfld * updating ioc api, experimenting with cron * save b4 thunder and lightning * plugin data reduction & args changes * freeze module after plugins, updateModule, and more * simplify plugin args and prepare for reduction among plugins * add deps to plugin calls and execute * plugin system loking better, tbd type * porg * initplugins inject deps, inconspicuos * fix faiklling test * fix initPlugins not reassigning * parsingParams kinda * proper mapping * dynamic customIds * handling customId params working * testing n shi * inlineinignsd * consolidate fmt * once on eventModules * refact,simplf * readd vitest and Asset fn * fix typings * assets fn complete * more intuitive context.options and Asset typings * add init hooks not firing * -file,-updateModule,publish? * fix: ioc deps not created correctly * documentation, add json for Asset * remove asset * ss * finish ioc transition * nvm, now i did * s * update locals api, docs, tests * fix tests * fix up tests and cleanup * fix * Update src/core/functions.ts Co-authored-by: Evo <85353424+EvolutionX-10@users.noreply.github.com> * better documentation * temp fix * namespace presence types again * revising cron modules and better error messages * scheduler ids * more descriptive errors * refactor to not type leak and job cancellation * refactor n better signatures for task scheduler * documentation * fix swap not accepting functions * change task signature --------- Co-authored-by: Evo <85353424+EvolutionX-10@users.noreply.github.com>
65 lines
2.5 KiB
TypeScript
65 lines
2.5 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import path from 'node:path'
|
|
import * as Files from '../../src/core/module-loading'
|
|
import { Module } from '../../src/types/core-modules'
|
|
import { AssertionError } from 'node:assert'
|
|
//TODO: mock fs?
|
|
describe('module-loading', () => {
|
|
it('should get the filename of the commandmodule (linux, esm)', () => {
|
|
const fname = "///home/pooba/Projects/sern/halibu/dist/commands/ping.js"
|
|
const callsiteinfo = Files.parseCallsite(fname)
|
|
expect(callsiteinfo.name).toBe("ping")
|
|
})
|
|
it('should get filename of commandmodule (linux, cjs)', () => {
|
|
const fname = "file:///home/pooba/Projects/sern/halibu/dist/commands/ping.js"
|
|
const callsiteinfo = Files.parseCallsite(fname)
|
|
expect(callsiteinfo.name).toBe("ping")
|
|
|
|
})
|
|
it('should get the filename of the commandmodule (windows, cjs)', () => {
|
|
//this test case is impossible on linux.
|
|
if(process.platform == 'win32') {
|
|
const fname = "C:\\pooba\\Projects\\sern\\halibu\\dist\\commands\\ping.js"
|
|
const callsiteinfo = Files.parseCallsite(fname)
|
|
expect(callsiteinfo.name).toEqual("ping");
|
|
}
|
|
})
|
|
it('should get filename of commandmodule (windows, esm)', () => {
|
|
//this test case is impossible on linux.
|
|
if(process.platform == 'win32') {
|
|
const fname = "file:///C:\\pooba\\Projects\\sern\\halibu\\dist\\commands\\ping.js"
|
|
const callsiteinfo = Files.parseCallsite(fname)
|
|
expect(callsiteinfo.name).toEqual("ping");
|
|
}
|
|
|
|
})
|
|
|
|
it('should import a commandModule properly', async () => {
|
|
const { module } = await Files.importModule<Module>(path.resolve("test", 'mockules', "module.ts"));
|
|
expect(module.name).toBe('module')
|
|
})
|
|
it('should throw when failed commandModule import', async () => {
|
|
try {
|
|
await Files.importModule(path.resolve('test', 'mockules', 'failed.ts'))
|
|
} catch(e) {
|
|
expect(e instanceof AssertionError)
|
|
}
|
|
})
|
|
it('should throw when failed commandModule import', async () => {
|
|
try {
|
|
await Files.importModule(path.resolve('test', 'mockules', 'failed.ts'))
|
|
} catch(e) {
|
|
expect(e instanceof AssertionError)
|
|
}
|
|
})
|
|
|
|
it('reads all modules in mockules', async () => {
|
|
const ps = [] as string[]
|
|
for await (const fpath of Files.readRecursive(path.resolve('test', 'mockules'))) {
|
|
ps.push(fpath)
|
|
}
|
|
expect(ps.length === 4)
|
|
})
|
|
|
|
})
|