-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(test): update regex for global matcher
- Loading branch information
1 parent
a08425d
commit 1db3491
Showing
3 changed files
with
632 additions
and
631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,56 @@ | ||
import ava from "ava" | ||
import "../../test-sdk/config.js" | ||
import { pathToFileURL } from "node:url" | ||
import ava from 'ava' | ||
import '../../test-sdk/config.js' | ||
import { pathToFileURL } from 'node:url' | ||
|
||
ava.serial("env should work with different params", async (t) => { | ||
let name = "mock-env-message" | ||
let content = ` | ||
ava.serial('env should work with different params', async (t) => { | ||
let name = 'mock-env-message' | ||
let content = ` | ||
await env("MOCK_ENV_MESSAGE", "Enter a value:") | ||
` | ||
let type = "js" | ||
let type = 'js' | ||
|
||
await exec(`kit new ${name} main --no-edit`, { | ||
env: { | ||
...process.env, | ||
KIT_NODE_PATH: process.execPath, | ||
KIT_MODE: type | ||
} | ||
}) | ||
await exec(`kit new ${name} main --no-edit`, { | ||
env: { | ||
...process.env, | ||
KIT_NODE_PATH: process.execPath, | ||
KIT_MODE: type | ||
} | ||
}) | ||
|
||
await appendFile(kenvPath("scripts", `${name}.js`), content) | ||
await appendFile(kenvPath('scripts', `${name}.js`), content) | ||
|
||
if (process.platform === "win32") { | ||
name += ".cmd" | ||
} | ||
if (process.platform === 'win32') { | ||
name += '.cmd' | ||
} | ||
|
||
let p = exec(`${kenvPath("bin", name)}`) | ||
let p = exec(`${kenvPath('bin', name)}`) | ||
|
||
p.stdin.write("Some value\n") | ||
p.stdin.write('Some value\n') | ||
|
||
let { stdout } = await p | ||
let { stdout } = await p | ||
|
||
t.regex(stdout, /env/) | ||
t.regex(stdout, /env/) | ||
}) | ||
|
||
ava.serial("All globals exist", async (t) => { | ||
// TODO: Make platform independent... | ||
/** @type {import("../platform/darwin")} */ | ||
await import(pathToFileURL(kitPath("core", "utils.js")).href) | ||
await import(pathToFileURL(kitPath("platform", "darwin.js")).href) | ||
await import(pathToFileURL(kitPath("target", "app.js")).href) | ||
await import(pathToFileURL(kitPath("api", "pro.js")).href) | ||
await import(pathToFileURL(kitPath("index.js")).href) | ||
|
||
let files = await readdir(kitPath("types")) | ||
let content = `` | ||
for await (let f of files) { | ||
content += await readFile(kitPath("types", f), "utf-8") | ||
} | ||
|
||
let matches = content | ||
.match(/(?<=var ).*?(?=:)/gim) | ||
.filter((m) => !m.includes("projectPath")) | ||
|
||
for (let m of matches) { | ||
t.log(`Checking if ${m} exists on global...`) | ||
t.true(typeof global[m] !== "undefined", `${m} is missing`) | ||
} | ||
ava.serial('All globals exist', async (t) => { | ||
// TODO: Make platform independent... | ||
/** @type {import("../platform/darwin")} */ | ||
await import(pathToFileURL(kitPath('core', 'utils.js')).href) | ||
await import(pathToFileURL(kitPath('platform', 'darwin.js')).href) | ||
await import(pathToFileURL(kitPath('target', 'app.js')).href) | ||
await import(pathToFileURL(kitPath('api', 'pro.js')).href) | ||
await import(pathToFileURL(kitPath('index.js')).href) | ||
|
||
let files = await readdir(kitPath('types')) | ||
let content = `` | ||
for await (let f of files) { | ||
content += await readFile(kitPath('types', f), 'utf-8') | ||
} | ||
|
||
let matches = content.match(/(?<=^\s*var ).*?(?=:)/gim).filter((m) => !m.includes('projectPath')) | ||
|
||
for (let m of matches) { | ||
t.log(`Checking if ${m} exists on global...`) | ||
t.true(typeof global[m] !== 'undefined', `${m} is missing`) | ||
} | ||
}) |
Oops, something went wrong.