MCPcopy Create free account
hub / github.com/openclaw/gogcli / TestDocsFormatFlagsBuildRequests

Function TestDocsFormatFlagsBuildRequests

internal/cmd/docs_format_test.go:17–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestDocsFormatFlagsBuildRequests(t *testing.T) {
18 t.Parallel()
19
20 reqs, err := (DocsFormatFlags{
21 FontFamily: "Georgia",
22 FontSize: 14,
23 TextColor: "#3366cc",
24 BgColor: "#fff",
25 NoBold: true,
26 Italic: true,
27 Alignment: "center",
28 LineSpacing: 150,
29 SpacingMode: "collapse_lists",
30 }).buildRequests(3, 9, "t.second")
31 if err != nil {
32 t.Fatalf("buildRequests: %v", err)
33 }
34 if len(reqs) != 2 {
35 t.Fatalf("expected text and paragraph requests, got %d", len(reqs))
36 }
37
38 textReq := reqs[0].UpdateTextStyle
39 if textReq == nil {
40 t.Fatalf("missing text request: %#v", reqs[0])
41 return
42 }
43 if got := textReq.Range; got.StartIndex != 3 || got.EndIndex != 9 || got.TabId != "t.second" {
44 t.Fatalf("unexpected text range: %#v", got)
45 }
46 if textReq.Fields != "weightedFontFamily,fontSize,foregroundColor,backgroundColor,bold,italic" {
47 t.Fatalf("unexpected text fields: %q", textReq.Fields)
48 }
49 if textReq.TextStyle.WeightedFontFamily.FontFamily != "Georgia" {
50 t.Fatalf("unexpected font: %#v", textReq.TextStyle.WeightedFontFamily)
51 }
52 if textReq.TextStyle.Bold {
53 t.Fatalf("bold should be false")
54 }
55
56 encoded, err := json.Marshal(textReq.TextStyle)
57 if err != nil {
58 t.Fatalf("marshal style: %v", err)
59 }
60 if !strings.Contains(string(encoded), `"bold":false`) {
61 t.Fatalf("clearing bold must force-send false, got %s", encoded)
62 }
63
64 paraReq := reqs[1].UpdateParagraphStyle
65 if paraReq == nil {
66 t.Fatalf("missing paragraph request: %#v", reqs[1])
67 return
68 }
69 if paraReq.ParagraphStyle.Alignment != "CENTER" || paraReq.ParagraphStyle.LineSpacing != 150 ||
70 paraReq.ParagraphStyle.SpacingMode != docsformat.SpacingModeCollapseLists {
71 t.Fatalf("unexpected paragraph style: %#v", paraReq.ParagraphStyle)
72 }
73 if got := paraReq.Range; got.TabId != "t.second" {
74 t.Fatalf("paragraph range lost tab id: %#v", got)

Callers

nothing calls this directly

Calls 1

buildRequestsMethod · 0.45

Tested by

no test coverage detected