mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { analyzeJavaScriptSemantics } from "./javascriptSemanticAnalysis.js";
|
|
import { responseConsumers } from "./javascriptSemanticResponseConsumers.fixture.js";
|
|
|
|
const consumers = (source: string) =>
|
|
responseConsumers(analyzeJavaScriptSemantics(source));
|
|
|
|
it.each([
|
|
'let response = await fetch("data:text/plain,original"); response = {text: () => "replacement"}; response.text();',
|
|
'async function load(response) { response.text(); response = await fetch("data:text/plain,original"); }',
|
|
])(
|
|
"qualifies a response candidate when its request does not prove the receiver: %s",
|
|
(source) => {
|
|
const result = consumers(source);
|
|
expect(result).toMatchObject([{ endpoint: null, resolution: "partial" }]);
|
|
expect(result[0]?.linkedRequestIds).toHaveLength(1);
|
|
},
|
|
);
|
|
|
|
it("keeps a response whose request definitely reaches the read complete", () => {
|
|
expect(
|
|
consumers(
|
|
'async function load(response) { response = await fetch("data:text/plain,original"); response.text(); }',
|
|
),
|
|
).toMatchObject([
|
|
{ endpoint: "data:text/plain,original", resolution: "complete" },
|
|
]);
|
|
});
|