cleanup-tests
Some checks failed
NPM / Publish / test-and-publish (push) Has been cancelled

This commit is contained in:
Jacob Nguyen
2025-01-07 17:33:33 -06:00
parent a575b3ed74
commit f2d4b5bda1
6 changed files with 108 additions and 168 deletions

30
test/setup/util.ts Normal file
View File

@@ -0,0 +1,30 @@
import { faker } from "@faker-js/faker"
import { CommandInitPlugin, CommandType, Module, controller } from "../../src"
import { Processed } from "../../src/types/core-modules"
import { vi } from 'vitest'
export function createRandomInitPlugin (s: 'go', mut?: Partial<Module>) {
return CommandInitPlugin(({ module }) => {
if(mut) {
Object.entries(mut).forEach(([k, v]) => {
module[k] = v
})
}
return s == 'go'
? controller.next()
: controller.stop()
})
}
export function createRandomModule(plugins: any[]): Processed<Module> {
return {
type: CommandType.Both,
meta: { id:"", absPath: "" },
description: faker.string.alpha(),
plugins,
name: "cheese",
onEvent: [],
locals: {},
execute: vi.fn(),
};
}