(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func 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 | } |
nothing calls this directly
no test coverage detected