Skip to content

Commit dd1acc4

Browse files
committed
test: snapshot Bundle.ts with generic propagation
1 parent 8be45c5 commit dd1acc4

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

test/api/write-generator/__snapshots__/typescript.test.ts.snap

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,3 +2125,75 @@ export { USCoreTribalAffiliationExtensionProfile } from "./Extension_USCoreTriba
21252125
export { USCoreVitalSignsProfile } from "./Observation_USCoreVitalSignsProfile";
21262126
"
21272127
`;
2128+
2129+
exports[`TypeScript Writer Generator generates Bundle with generic entry type (nested generic propagation) 1`] = `
2130+
"// WARNING: This file is autogenerated by @atomic-ehr/codegen.
2131+
// GitHub: https://github.com/atomic-ehr/codegen
2132+
// Any manual changes made to this file may be overwritten.
2133+
2134+
import type { BackboneElement } from "../hl7-fhir-r4-core/BackboneElement";
2135+
import type { Identifier } from "../hl7-fhir-r4-core/Identifier";
2136+
import type { Resource } from "../hl7-fhir-r4-core/Resource";
2137+
import type { Signature } from "../hl7-fhir-r4-core/Signature";
2138+
2139+
import type { Element } from "../hl7-fhir-r4-core/Element";
2140+
export type { BackboneElement } from "../hl7-fhir-r4-core/BackboneElement";
2141+
export type { Identifier } from "../hl7-fhir-r4-core/Identifier";
2142+
export type { Signature } from "../hl7-fhir-r4-core/Signature";
2143+
2144+
export interface BundleEntry<T extends Resource = Resource> extends BackboneElement {
2145+
fullUrl?: string;
2146+
link?: BundleLink[];
2147+
request?: BundleEntryRequest;
2148+
resource?: T;
2149+
response?: BundleEntryResponse;
2150+
search?: BundleEntrySearch;
2151+
}
2152+
2153+
export interface BundleEntryRequest extends BackboneElement {
2154+
ifMatch?: string;
2155+
ifModifiedSince?: string;
2156+
ifNoneExist?: string;
2157+
ifNoneMatch?: string;
2158+
method: ("GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "PATCH");
2159+
url: string;
2160+
}
2161+
2162+
export interface BundleEntryResponse<T extends Resource = Resource> extends BackboneElement {
2163+
etag?: string;
2164+
lastModified?: string;
2165+
location?: string;
2166+
outcome?: T;
2167+
status: string;
2168+
}
2169+
2170+
export interface BundleEntrySearch extends BackboneElement {
2171+
mode?: ("match" | "include" | "outcome");
2172+
score?: number;
2173+
}
2174+
2175+
export interface BundleLink extends BackboneElement {
2176+
relation: string;
2177+
url: string;
2178+
}
2179+
2180+
// CanonicalURL: http://hl7.org/fhir/StructureDefinition/Bundle (pkg: hl7.fhir.r4.core#4.0.1)
2181+
export interface Bundle<T extends Resource = Resource> extends Resource {
2182+
resourceType: "Bundle";
2183+
2184+
entry?: BundleEntry<T>[];
2185+
identifier?: Identifier;
2186+
link?: BundleLink[];
2187+
signature?: Signature;
2188+
timestamp?: string;
2189+
_timestamp?: Element;
2190+
total?: number;
2191+
_total?: Element;
2192+
type: ("document" | "message" | "transaction" | "transaction-response" | "batch" | "batch-response" | "history" | "searchset" | "collection");
2193+
_type?: Element;
2194+
}
2195+
export const isBundle = (resource: unknown): resource is Bundle => {
2196+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "Bundle";
2197+
}
2198+
"
2199+
`;

test/api/write-generator/typescript.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe("TypeScript Writer Generator", async () => {
3434
const bundleTs = files["generated/types/hl7-fhir-r4-core/Bundle.ts"];
3535
expect(bundleTs).toContain("export interface Bundle<T extends Resource = Resource>");
3636
expect(bundleTs).toContain("entry?: BundleEntry<T>[]");
37+
expect(bundleTs).toMatchSnapshot();
3738
});
3839
it("generates BundleEntryResponse with generic type-family parameter", async () => {
3940
const bundleTs = files["generated/types/hl7-fhir-r4-core/Bundle.ts"];

0 commit comments

Comments
 (0)