Add expression completion tests

This commit is contained in:
Jacob Wallraff
2022-12-16 11:34:06 -08:00
parent 9b8fd40344
commit 365a8dfca2
2 changed files with 64 additions and 11 deletions
@@ -684,20 +684,73 @@ jobs:
runs-on: ubuntu-latest
container:
image: node:14.16
services:
nginx:
image: node:14.16
steps:
- run: echo \${{ job.| }}
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toContain("container");
expect(result.map(x => x.label)).toContain("services");
expect(result.map(x => x.label)).toContain("status");
expect(result.map(x => x.label)).toEqual(["container", "services", "status"]);
});
it("job context is suggested within a job", async () => {
it("container context is suggested within a job container", async () => {
const input = `
on: push
jobs:
test:
runs-on: ubuntu-latest
container:
image: node:14.16
steps:
- run: echo \${{ job.container.| }}
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toEqual(["id", "network"]);
});
it("job context is suggested within a job", async () => {
it("services are suggested within a job services list", async () => {
const input = `
on: push
jobs:
test:
runs-on: ubuntu-latest
services:
nginx:
image: node:14.16
redis:
image: redis
steps:
- run: echo \${{ job.services.| }}
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toEqual(["nginx", "redis"]);
});
it("services context is suggested within a job service", async () => {
const input = `
on: push
jobs:
test:
runs-on: ubuntu-latest
services:
nginx:
image: node:14.16
ports:
- 80:8080
- 90
steps:
- run: echo \${{ job.services.nginx.| }}
`;
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toEqual(["id", "network", "ports"]);
});
});
+6 -6
View File
@@ -701,9 +701,9 @@
"link": true
},
"node_modules/@github/actions-workflow-parser": {
"version": "0.0.35",
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.35/0e88d541486f7c8772c5640fc13fac630cfaeaa8",
"integrity": "sha512-OuNEuqUH4AOfWd2xb8VRl7KwJrtiZu1ic0b27lmadwvK8qgRhPHxvS+QICEc+JtFbbVWpAA2ymh8I1U35639mA==",
"version": "0.0.36",
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.36/f27b908936efa949a105d7192dd3787a15094d71",
"integrity": "sha512-ATResf0PCT/bftJgs2ROAo0gDMIKQ1X0HcB4GejuYTcyHxWfvC44EqvFZmMpurV4Camht20bqK3LSY4NoJ0aVQ==",
"license": "MIT",
"dependencies": {
"@github/actions-expressions": "*",
@@ -13539,9 +13539,9 @@
}
},
"@github/actions-workflow-parser": {
"version": "0.0.35",
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.35/0e88d541486f7c8772c5640fc13fac630cfaeaa8",
"integrity": "sha512-OuNEuqUH4AOfWd2xb8VRl7KwJrtiZu1ic0b27lmadwvK8qgRhPHxvS+QICEc+JtFbbVWpAA2ymh8I1U35639mA==",
"version": "0.0.36",
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.36/f27b908936efa949a105d7192dd3787a15094d71",
"integrity": "sha512-ATResf0PCT/bftJgs2ROAo0gDMIKQ1X0HcB4GejuYTcyHxWfvC44EqvFZmMpurV4Camht20bqK3LSY4NoJ0aVQ==",
"requires": {
"@github/actions-expressions": "*",
"yaml": "^2.0.0-8"