oficina / fichas Public

Clone
git clone https://amadan.net/oficina/fichas

Plain git — no account needed to clone.

Download

Download this file

1package fichas
2
3import (
4 "slices"
5 "testing"
6)
7
8// File is the first menu, as in Docs, Slides and Mapa (level-up build
9// note 24), and keeps what Card held: New, then on a card Open full
10// page, History and Delete…, last and set apart. Fichas has no importer
11// yet, so File has no Import row.
12func TestFileIsTheFirstMenu(t *testing.T) {
13 for _, check := range []struct {
14 facts frameFacts
15 want []string
16 }{
17 {frameFacts{}, []string{"New card"}},
18 {frameFacts{TypeKey: "t_customer", Singular: "Customer"},
19 []string{"New customer"}},
20 {frameFacts{TypeKey: "t_customer", Singular: "Customer", CardID: 7},
21 []string{"New customer", "Open full page", "History", "—",
22 "Delete…"}},
23 } {
24 bar := menusFor(check.facts)
25 var titles []string
26 for _, menu := range bar.Menus {
27 titles = append(titles, menu.Title)
28 }
29 if !slices.Equal(titles, []string{"File", "Edit", "View", "Type",
30 "Help"}) {
31 t.Fatalf("the menus are %q", titles)
32 }
33 file := bar.Menus[0]
34 if file.ID != "file" {
35 t.Errorf("File's id is %q", file.ID)
36 }
37 var rows []string
38 for _, item := range file.Items {
39 if item.Kind == "divider" {
40 rows = append(rows, "—")
41 continue
42 }
43 rows = append(rows, item.Label)
44 }
45 if !slices.Equal(rows, check.want) {
46 t.Errorf("%+v: File is %q, want %q", check.facts, rows,
47 check.want)
48 }
49 }
50}
51