Skip to content

Commit 966b6f8

Browse files
franklinfollissgammon
authored andcommitted
test(non-entrypoint-import): add smoke test for special prefix imports in typescript
1 parent 3fc216c commit 966b6f8

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

packages/cli/src/test/kotlin/elide/tool/cli/ElideSmokeTests.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import elide.testing.annotations.TestCase
7070
testFile("hello-fn.mts"),
7171
testFile("hello-import.mts"),
7272
testFile("hello-import-js.mts"),
73+
testFile("import-prefix-test.ts"),
7374
testFile("paths.cjs"),
7475
testFile("paths.mjs"),
7576
testFile("paths-default.mjs"),
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/// <reference path="../../packages/types/index.d.ts" />
2+
3+
import { Database } from "elide:sqlite"
4+
import { ok } from "node:assert"
5+
6+
export function createDatabase(): Database {
7+
const db = new Database(":memory:")
8+
ok(db, "Database should be created")
9+
return db
10+
}
11+
12+
export function testDatabase() {
13+
const db = createDatabase()
14+
15+
db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT, value INTEGER);")
16+
db.exec("INSERT INTO test (name, value) VALUES ('foo', 42);")
17+
db.exec("INSERT INTO test (name, value) VALUES ('bar', 84);")
18+
19+
const query = db.query("SELECT * FROM test;")
20+
const results = query.all()
21+
22+
ok(results.length === 2, `Expected 2 results, got ${results.length}`)
23+
ok(results[0].name === "foo", `Expected name 'foo', got '${results[0].name}'`)
24+
ok(results[0].value === 42, `Expected value 42, got ${results[0].value}`)
25+
ok(results[1].name === "bar", `Expected name 'bar', got '${results[1].name}'`)
26+
ok(results[1].value === 84, `Expected value 84, got ${results[1].value}`)
27+
28+
db.close()
29+
console.info("Database test passed")
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path="../../packages/types/index.d.ts" />
2+
3+
import { testDatabase } from "./import-prefix-helpers.ts"
4+
5+
console.info("Testing multi-file imports with elide:* modules...")
6+
testDatabase()
7+
console.info("All tests passed!")

0 commit comments

Comments
 (0)