Skip to content

Commit 1bfca54

Browse files
committed
Inline reassignment test source
1 parent cf24ea9 commit 1bfca54

2 files changed

Lines changed: 3 additions & 22 deletions

File tree

game-scripts-tests/reassignment_to_const_is_invalid.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/processScript/index.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import rollupPluginNodeResolve from "@rollup/plugin-node-resolve"
2727
import type { LaxPartial } from "@samual/lib"
2828
import { assert } from "@samual/lib/assert"
2929
import { readFile, readdir as readFolder } from "fs/promises"
30-
import { basename as getPathBasename, relative as getRelativePath, isAbsolute as isAbsolutePath, sep as pathSeparator, resolve as resolvePath, join as joinPath } from "path"
30+
import { basename as getPathBasename, relative as getRelativePath, isAbsolute as isAbsolutePath, sep as pathSeparator, resolve as resolvePath } from "path"
3131
import prettier from "prettier"
3232
import { rollup } from "rollup"
3333
import { supportedExtensions as extensions } from "../constants"
@@ -418,14 +418,12 @@ export async function processScript(code: string, {
418418
if (import.meta.vitest) {
419419
const DEBUG_LOG_PROCESSED_SCRIPTS = false
420420
const TESTS_FOLDER = `game-scripts-tests`
421-
const REASSIGNMENT_TEST_FILE = `reassignment_to_const_is_invalid.ts`
422421

423422
const { test, expect } = import.meta.vitest
424423

425424
const testFiles = await Promise.all(
426425
(await readFolder(TESTS_FOLDER, { withFileTypes: true }))
427426
.filter(dirent => dirent.isFile())
428-
.filter(dirent => dirent.name != REASSIGNMENT_TEST_FILE)
429427
.map(async dirent => {
430428
const filePath = getRelativePath(`.`, resolvePath(TESTS_FOLDER, dirent.name))
431429
const source = await readFile(filePath, `utf8`)
@@ -447,16 +445,8 @@ if (import.meta.vitest) {
447445
})
448446
}
449447

450-
const reassignmentTestPath = joinPath(TESTS_FOLDER, REASSIGNMENT_TEST_FILE)
451-
const reassignmentTestSource = await readFile(reassignmentTestPath, `utf8`)
452-
453-
const options: ProcessOptions = {
454-
scriptName: REASSIGNMENT_TEST_FILE,
455-
filePath: reassignmentTestPath,
456-
minify: false
457-
}
458-
459-
expect(async () => await processScript(reassignmentTestSource, options))
448+
const reassignmentTestSource = `export default () => { const i = 0; i = 1; }`
449+
expect(async (): Promise<any> => await processScript(reassignmentTestSource, { scriptName: true, minify: false }))
460450
.rejects
461451
.toThrowError(`Reassignment to const variable i is not allowed!`)
462452
}

0 commit comments

Comments
 (0)