Files
languageservices/actions-languageservice/src/hover.test.ts
T

65 lines
2.4 KiB
TypeScript
Raw Normal View History

2022-11-21 17:21:40 -05:00
import {TextDocument} from "vscode-languageserver-textdocument";
import {hover} from "./hover";
2022-11-30 14:39:21 -05:00
import {getPositionFromCursor} from "./test-utils/cursor-position";
2022-11-21 17:21:40 -05:00
describe("hover", () => {
2022-12-02 15:23:15 -05:00
it("on a key", async () => {
2022-11-30 14:39:21 -05:00
const input = `o|n: push
2022-11-21 17:21:40 -05:00
jobs:
build:
2022-11-30 14:39:21 -05:00
runs-on: [self-hosted]`;
const result = await hover(...getPositionFromCursor(input));
2022-11-21 17:21:40 -05:00
expect(result).not.toBeUndefined();
expect(result?.contents).toEqual(
"The name of the GitHub event that triggers the workflow. You can provide a single event string, array of events, array of event types, or an event configuration map that schedules a workflow or restricts the execution of a workflow to specific files, tags, or branch changes. For a list of available events, see https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows."
);
});
2022-12-02 15:23:15 -05:00
it("on a value", async () => {
2022-11-30 14:39:21 -05:00
const input = `on: pu|sh
2022-11-21 17:21:40 -05:00
jobs:
build:
2022-11-30 14:39:21 -05:00
runs-on: [self-hosted]`;
const result = await hover(...getPositionFromCursor(input));
2022-11-30 14:39:21 -05:00
expect(result).not.toBeUndefined();
expect(result?.contents).toEqual("Runs your workflow when you push a commit or tag.");
});
2023-01-06 13:32:53 -08:00
it("on a parameter with a description", async () => {
const input = `on: push
jobs:
build:
co|ntinue-on-error: false`;
const result = await hover(...getPositionFromCursor(input));
expect(result).not.toBeUndefined();
expect(result?.contents).toEqual(
"Prevents a workflow run from failing when a job fails. Set to true to allow a workflow run to pass when this job fails.\n\n" +
"**Context:** github, inputs, vars, needs, strategy, matrix"
);
});
it("on a parameter with its own type", async () => {
const input = `on: push
jobs:
build:
pe|rmissions: read-all`;
const result = await hover(...getPositionFromCursor(input));
expect(result).not.toBeUndefined();
expect(result?.contents).toEqual(
"You can modify the default permissions granted to the GITHUB_TOKEN, adding or removing access as required, so that you only allow the minimum required access."
);
});
2022-12-02 15:23:15 -05:00
it("on a value in a sequence", async () => {
2022-11-30 14:39:21 -05:00
const input = `on: [pull_request,
pu|sh]
jobs:
build:
runs-on: [self-hosted]`;
const result = await hover(...getPositionFromCursor(input));
2022-11-30 14:39:21 -05:00
expect(result).not.toBeUndefined();
expect(result?.contents).toEqual("Runs your workflow when you push a commit or tag.");
2022-11-08 17:00:59 -08:00
});
});