MCPcopy Create free account
hub / github.com/hashintel/hash / index

Function index

libs/@local/codec/tests/codegen.rs:13–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12#[test]
13fn index() -> io::Result<()> {
14 let collection = TypeCollection::default();
15
16 let settings = TypeScriptGeneratorSettings::default();
17 let mut generator = TypeScriptGenerator::new(&settings, &collection);
18
19 for (type_id, _, type_definition) in collection.iter() {
20 if type_definition.module.starts_with("hash_codec") {
21 generator.add_type_declaration_by_id(type_id);
22 }
23 }
24
25 insta::with_settings!({
26 description => "Generated TS types",
27 omit_expression => true,
28 snapshot_path => "../types",
29 prepend_module_to_snapshot => false,
30 }, {
31 insta::assert_binary_snapshot!(
32 ".d.ts",
33 format!("// This file was generated from `{}`\n\n{}", file!(), generator.write()).into_bytes()
34 );
35 });
36
37 // We require a `.js` file as otherwise `tsc` won't find the `.d.ts` file
38 let _: fs::File = fs::File::options()
39 .create(true)
40 .write(true)
41 .truncate(true)
42 .open(
43 Path::new(env!("CARGO_MANIFEST_DIR"))
44 .join("types")
45 .join("index.snap.js"),
46 )?;
47
48 Ok(())
49}

Callers

nothing calls this directly

Calls 10

OkInterface · 0.85
openMethod · 0.80
truncateMethod · 0.80
defaultFunction · 0.50
iterMethod · 0.45
starts_withMethod · 0.45
writeMethod · 0.45
createMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected