mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
f738ccf4b5
* 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
32 lines
1.2 KiB
TypeScript
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");
|
|
});
|
|
});
|