package socketio import ( "encoding/json" "testing" ) func TestBuildEventFrame(t *testing.T) { body, _ := json.Marshal([]any{"hello", map[string]any{"x": 1}}) got := string(buildEventFrame("/realtime", body)) want := `42/realtime,["hello",{"x":1}]` if got != want { t.Errorf("got %q\nwant %q", got, want) } } func TestBuildEventFrameRootNamespace(t *testing.T) { body, _ := json.Marshal([]any{"ping"}) got := string(buildEventFrame("", body)) if got != `42["ping"]` { t.Errorf("got %q", got) } got2 := string(buildEventFrame("/", body)) if got2 != `42["ping"]` { t.Errorf("got %q", got2) } }