MCPcopy
hub / github.com/esm-dev/esm.sh / TestEncodeBuildMeta

Function TestEncodeBuildMeta

server/build_meta_test.go:8–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestEncodeBuildMeta(t *testing.T) {
9 meta1 := &BuildMeta{
10 CJS: true,
11 CSSInJS: true,
12 TypesOnly: true,
13 ExportDefault: true,
14 CSSEntry: "./index.css",
15 Dts: "./types/index.d.ts",
16 Imports: []string{"/react@19.2.4?target=es2022", "/react-dom@19.2.4?target=es2022"},
17 Integrity: "sha384-...",
18 }
19 data := encodeBuildMeta(meta1)
20 meta2, err := decodeBuildMeta(data)
21 if err != nil {
22 t.Fatal(err)
23 }
24 if !reflect.DeepEqual(meta1, meta2) {
25 t.Fatalf("meta mismatch: %+v != %+v", meta1, meta2)
26 }
27 meta3, err := decodeBuildMeta([]byte("ESM\r\nwhatever"))
28 if err != nil {
29 t.Fatal(err)
30 }
31 metaEmpty := &BuildMeta{}
32 if !reflect.DeepEqual(meta3, metaEmpty) {
33 t.Fatalf("meta mismatch: %+v != %+v", meta3, metaEmpty)
34 }
35}

Callers

nothing calls this directly

Calls 2

encodeBuildMetaFunction · 0.85
decodeBuildMetaFunction · 0.85

Tested by

no test coverage detected