-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathdetect.spec.ts
More file actions
67 lines (63 loc) · 2.96 KB
/
detect.spec.ts
File metadata and controls
67 lines (63 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { convertToUnixPaths } from "../../test.helpers.js";
import { detectDbConfigFiles, detectProjectFolders, formatDetectedFolders, generateConfiguration } from "./detect.js";
describe("framework detection", () => {
describe("detectProjectFolders()", () => {
it("should detect frameworks", async () => {
const detectedFolders = convertToUnixPaths(await detectProjectFolders("e2e/fixtures"));
expect(detectedFolders.api.length).toBe(2);
expect(detectedFolders.app.length).toBe(2);
expect(formatDetectedFolders(detectedFolders.api, "api")).toMatchInlineSnapshot(`
"Detected api folders (2):
- e2e/fixtures/astro-node/node (Node.js)
- e2e/fixtures/static-node-ts/node-ts (Node.js, TypeScript)"
`);
expect(formatDetectedFolders(detectedFolders.app, "app")).toMatchInlineSnapshot(`
"Detected app folders (2):
- e2e/fixtures/static-node-ts (Static HTML)
- e2e/fixtures/astro-node/astro preact (Astro)"
`);
});
});
describe("generateConfiguration()", () => {
it("should generate expected configuration for app astro-node", async () => {
const { app, api } = await detectProjectFolders("e2e/fixtures/astro-node");
const config = convertToUnixPaths(await generateConfiguration(app[0], api[0]));
expect(config).toEqual({
apiBuildCommand: "npm run build --if-present",
apiLocation: "e2e/fixtures/astro-node/node",
appBuildCommand: "npm run build",
appLocation: "e2e/fixtures/astro-node/astro preact",
appDevserverCommand: "npm run dev",
apiLanguage: "node",
apiVersion: "22",
appDevserverUrl: "http://localhost:8080",
name: "Astro, with API: Node.js",
outputLocation: "_site",
});
});
it("should generate expected configuration for app static-node-ts", async () => {
const { app, api } = await detectProjectFolders("e2e/fixtures/static-node-ts");
const config = convertToUnixPaths(await generateConfiguration(app[0], api[0]));
expect(config).toEqual({
apiBuildCommand: "npm run build --if-present",
apiLocation: "e2e/fixtures/static-node-ts/node-ts",
appLocation: "e2e/fixtures/static-node-ts",
name: "Static HTML, with API: Node.js, TypeScript",
apiLanguage: "node",
apiVersion: "22",
outputLocation: ".",
});
});
it("should generate expected configuration for app static-mssql", async () => {
const { app, api } = await detectProjectFolders("e2e/samples/db/static-mssql");
const dataApi = await detectDbConfigFiles("e2e/samples/db/static-mssql");
const config = convertToUnixPaths(await generateConfiguration(app[0], api[0], dataApi[0]));
expect(config).toEqual({
dataApiLocation: "e2e/samples/db/static-mssql/swa-db-connections",
appLocation: "e2e/samples/db/static-mssql/src",
name: "Static HTML, data API: mssql",
outputLocation: ".",
});
});
});
});