Files
cloudflare__vinext/tests/pages-route-data-kind.test.ts
James Anderson f738ccf4b5 refactor(pages): extract response stage (#3145)
* refactor(pages): extract response stage

* fix(pages): avoid replaying staged response headers

* fix(pages): preserve staged cookie boundaries

* fix(pages): retain additive edge cookies

* fix(pages): bypass shared stages for WebSocket upgrades

* fix(pages): parse WebSocket upgrade tokens

* refactor(pages): expose response stage at first use

* fix(cache): classify Pages APIs by matched route kind

* test(cache): cover Pages admission without HTML accept

* test(cache): assert private Pages fallback policy

* test(cache): accept equivalent private fallback directives
2026-09-07 21:48:25 +01:00

32 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vite-plus/test";
import { getRuntimePagesDataKind } from "../packages/vinext/src/server/pages-route-data-kind.js";
describe("getRuntimePagesDataKind", () => {
it("uses the loaded page after HOCs and re-exports have run", () => {
expect(getRuntimePagesDataKind({ default: { getInitialProps() {} } }, null)).toBe("initial");
});
it("detects custom _app getInitialProps but not the inherited default", () => {
const inherited = () => ({});
expect(
getRuntimePagesDataKind({}, { getInitialProps: inherited, origGetInitialProps: inherited }),
).toBe("none");
expect(
getRuntimePagesDataKind({}, { getInitialProps() {}, origGetInitialProps: inherited }),
).toBe("initial");
});
it("keeps getStaticProps authoritative over _app and page initial props", () => {
expect(
getRuntimePagesDataKind(
{ default: { getInitialProps() {} }, getStaticProps() {} },
{ getInitialProps() {} },
),
).toBe("static");
});
it("classifies getServerSideProps as request-time", () => {
expect(getRuntimePagesDataKind({ getServerSideProps() {} }, null)).toBe("server");
});
});