Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joheredi committed Feb 13, 2025
1 parent eba5ba7 commit cfacfe4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@
"generate-tmlanguage": "node scripts/generate-tmlanguage.js",
"gen-extern-signature": "tsx ./.scripts/gen-extern-signature.ts",
"dogfood": "node scripts/dogfood.js",
"test": "vitest run",
"test": "cross-env NODE_ENV=production vitest run",
"test:ui": "vitest --ui",
"test:watch": "vitest -w",
"test:ci": "vitest run --coverage --reporter=junit --reporter=default",
"test:e2e": "vitest run --config ./vitest.config.e2e.ts",
"test:ci": "cross-env NODE_ENV=production vitest run --coverage --reporter=junit --reporter=default",
"test:e2e": "cross-env NODE_ENV=production vitest run --config ./vitest.config.e2e.ts",
"gen-manifest": "node scripts/generate-manifest.js",
"regen-nonascii": "node scripts/regen-nonascii.js",
"fuzz": "node dist/test/manual/fuzz.js run",
Expand Down
4 changes: 3 additions & 1 deletion packages/compiler/src/core/program.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {render, OutputDirectory} from "@alloy-js/core"
import { type OutputDirectory } from "@alloy-js/core";
import { EmitterOptions } from "../config/types.js";
import { createAssetEmitter } from "../emitter-framework/asset-emitter.js";
import { setCurrentProgram } from "../experimental/typekit/index.js";
Expand Down Expand Up @@ -580,6 +580,8 @@ export async function compile(
try {
const result = (await emitter.emitFunction(context)) as any;
if (typeof result === "function") {
// import {render, OutputDirectory} from "@alloy-js/core"
const {render} = await import("@alloy-js/core");
// assume this is an alloy component
const tree = render(result);
await writeOutputDirectory(tree, context.emitterOutputDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ describe("Typescript Interface", () => {
const actualContent = await format(testFile.contents as string, { parser: "typescript" });
const expectedContent = await format(
`
export interface DifferentSpreadModelRecord extends Record<string, unknown> {
export interface DifferentSpreadModelRecord {
knownProp: string;
additionalProperties?: Record<string, unknown>;
}
`,
{
Expand Down Expand Up @@ -110,7 +111,9 @@ describe("Typescript Interface", () => {
assert(testFile, "test.ts file not rendered");
const actualContent = await format(testFile.contents as string, { parser: "typescript" });
const expectedContent = await format(
`export interface Foo extends Record<string, unknown> { }
`export interface Foo {
additionalProperties?: Record<string, string>;
}
`,
{
parser: "typescript",
Expand Down Expand Up @@ -148,7 +151,9 @@ describe("Typescript Interface", () => {
const actualContent = await format(testFile.contents as string, { parser: "typescript" });
const expectedContent = await format(
`
export interface Foo extends Record<string, unknown> { }
export interface Foo {
additionalProperties?: Record<string, string>;
}
`,
{
parser: "typescript",
Expand Down Expand Up @@ -197,8 +202,9 @@ describe("Typescript Interface", () => {
`export interface ModelForRecord {
state: string;
}
export interface DifferentSpreadModelRecord extends Record<string, unknown> {
export interface DifferentSpreadModelRecord {
knownProp: string;
additionalProperties?: Record<string, ModelForRecord>;
}
export interface DifferentSpreadModelDerived extends DifferentSpreadModelRecord {
derivedProp: ModelForRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("Typescript Type Alias Declaration", () => {
const testFile = res.contents.find((file) => file.path === "test.ts");
assert(testFile, "test.ts file not rendered");
const actualContent = await format(testFile.contents as string, { parser: "typescript" });
const expectedContent = await format(`type MyDate = number;`, {
const expectedContent = await format(`type MyDate = Date;`, {
parser: "typescript",
});
expect(actualContent).toBe(expectedContent);
Expand Down

0 comments on commit cfacfe4

Please sign in to comment.