mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-21 16:00:59 -05:00
Added tests for action-metadata
This commit is contained in:
parent
df180e76ab
commit
498acbb63f
1 changed files with 140 additions and 0 deletions
140
tests/unit/utils/actions/action-metadata.spec.ts
Normal file
140
tests/unit/utils/actions/action-metadata.spec.ts
Normal file
|
@ -0,0 +1,140 @@
|
|||
import mockFs from "mock-fs";
|
||||
import { parseActionMetadataFromFile, parseActionMetadataFromString } from "@/utils/actions/action-metadata";
|
||||
|
||||
beforeEach(() => {
|
||||
mockFs({
|
||||
"action.yml": `
|
||||
name: Test Action
|
||||
description: This is a test action
|
||||
inputs:
|
||||
- name: input1
|
||||
description: This is input1
|
||||
type: string
|
||||
- name: input2
|
||||
description: This is input2
|
||||
type: number
|
||||
`,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
mockFs.restore();
|
||||
});
|
||||
|
||||
describe("parseActionMetadataFromString", () => {
|
||||
test("returns the parsed ActionMetadata object for valid YAML text", () => {
|
||||
const actionYamlText = `
|
||||
name: Test Action
|
||||
description: This is a test action
|
||||
inputs:
|
||||
- name: input1
|
||||
description: This is input1
|
||||
type: string
|
||||
- name: input2
|
||||
description: This is input2
|
||||
type: number
|
||||
`;
|
||||
|
||||
const result = parseActionMetadataFromString(actionYamlText);
|
||||
|
||||
expect(result).toEqual({
|
||||
name: "Test Action",
|
||||
description: "This is a test action",
|
||||
inputs: [
|
||||
{ name: "input1", description: "This is input1", type: "string" },
|
||||
{ name: "input2", description: "This is input2", type: "number" },
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseActionMetadataFromFile", () => {
|
||||
test("reads the file and parses the content as ActionMetadata", async () => {
|
||||
const result = await parseActionMetadataFromFile("action.yml");
|
||||
|
||||
expect(result).toEqual({
|
||||
name: "Test Action",
|
||||
description: "This is a test action",
|
||||
inputs: [
|
||||
{ name: "input1", description: "This is input1", type: "string" },
|
||||
{ name: "input2", description: "This is input2", type: "number" },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test("throws an error if the file doesn't exist", async () => {
|
||||
await expect(parseActionMetadataFromFile("action.txt")).rejects.toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe("processActionMetadataTemplate", () => {
|
||||
test("assume that everything is fine, until it's not", () => {
|
||||
// This method is only used for code generation during
|
||||
// TypeScript-to-JavaScript transpilation. Thus, there's
|
||||
// no need to expend effort testing code that would cause
|
||||
// a compilation error if something was actually wrong.
|
||||
});
|
||||
});
|
||||
|
||||
describe("processActionMetadataTemplateString", () => {
|
||||
test("assume that everything is fine, until it's not", () => {
|
||||
// This method is only used for code generation during
|
||||
// TypeScript-to-JavaScript transpilation. Thus, there's
|
||||
// no need to expend effort testing code that would cause
|
||||
// a compilation error if something was actually wrong.
|
||||
});
|
||||
});
|
||||
|
||||
describe("processActionMetadataTemplateFile", () => {
|
||||
test("assume that everything is fine, until it's not", () => {
|
||||
// This method is only used for code generation during
|
||||
// TypeScript-to-JavaScript transpilation. Thus, there's
|
||||
// no need to expend effort testing code that would cause
|
||||
// a compilation error if something was actually wrong.
|
||||
});
|
||||
});
|
||||
|
||||
describe("createTypeScriptDefinitionForActionMetadata", () => {
|
||||
test("assume that everything is fine, until it's not", () => {
|
||||
// This method is only used for code generation during
|
||||
// TypeScript-to-JavaScript transpilation. Thus, there's
|
||||
// no need to expend effort testing code that would cause
|
||||
// a compilation error if something was actually wrong.
|
||||
});
|
||||
});
|
||||
|
||||
describe("createModuleLoaderTypeScriptDefinitionForActionMetadata", () => {
|
||||
test("assume that everything is fine, until it's not", () => {
|
||||
// This method is only used for code generation during
|
||||
// TypeScript-to-JavaScript transpilation. Thus, there's
|
||||
// no need to expend effort testing code that would cause
|
||||
// a compilation error if something was actually wrong.
|
||||
});
|
||||
});
|
||||
|
||||
describe("stripActionMetadataFromCustomFields", () => {
|
||||
test("assume that everything is fine, until it's not", () => {
|
||||
// This method is only used for code generation during
|
||||
// TypeScript-to-JavaScript transpilation. Thus, there's
|
||||
// no need to expend effort testing code that would cause
|
||||
// a compilation error if something was actually wrong.
|
||||
});
|
||||
});
|
||||
|
||||
describe("stripActionMetadataStringFromCustomFields", () => {
|
||||
test("assume that everything is fine, until it's not", () => {
|
||||
// This method is only used for code generation during
|
||||
// TypeScript-to-JavaScript transpilation. Thus, there's
|
||||
// no need to expend effort testing code that would cause
|
||||
// a compilation error if something was actually wrong.
|
||||
});
|
||||
});
|
||||
|
||||
describe("stripActionMetadataFileFromCustomFields", () => {
|
||||
test("assume that everything is fine, until it's not", () => {
|
||||
// This method is only used for code generation during
|
||||
// TypeScript-to-JavaScript transpilation. Thus, there's
|
||||
// no need to expend effort testing code that would cause
|
||||
// a compilation error if something was actually wrong.
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue