34 lines
959 B
TypeScript
34 lines
959 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { migrateV060WrnSource } from "../src/update.ts";
|
|
|
|
const report = () => ({
|
|
changedAutomatically: [],
|
|
needsReview: [],
|
|
unresolvedImports: [],
|
|
ambiguousFunctions: [],
|
|
legacyOutputPayloads: [],
|
|
parseFailures: [],
|
|
});
|
|
|
|
describe("v0.6 source migration", () => {
|
|
test("converts legacy outputs and remains idempotent", () => {
|
|
const input = `component Demo {
|
|
props {
|
|
@event confirm = function
|
|
}
|
|
functions {
|
|
function confirm() {
|
|
$emit("confirm", { ok: true })
|
|
}
|
|
}
|
|
view { <button @click='confirm()'>Confirm</button> }
|
|
}`;
|
|
const first = migrateV060WrnSource(input, report(), "Demo.wrn");
|
|
const second = migrateV060WrnSource(first, report(), "Demo.wrn");
|
|
expect(first).toContain("outputs {");
|
|
expect(first).toContain("confirm(payload: unknown)");
|
|
expect(first).toContain("output.confirm({ ok: true })");
|
|
expect(second).toBe(first);
|
|
});
|
|
});
|