cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

main
012 / e2e / format_test.go
format_test.go 2.2K
1package e2e23import (4 "strings"5 "testing"6)78func TestTypeDateAndApplyCurrency(t *testing.T) {9 t.Parallel()10 s := start(t, "")11 s.keys("9/26/2026", "<enter>", "2026-09-27", "<enter>", "14:30", "<enter>")12 s.waitForLine(gridRow1, numRow(1, "9/26/2026"))13 s.waitForLine(gridRow1+1, numRow(2, "2026-09-27"))14 s.waitForLine(gridRow1+2, numRow(3, "14:30:00"))1516 // Dates are numbers: the day after is one more.17 s.keys("=A1+1", "<enter>")18 s.waitForLine(gridRow1+3, numRow(4, "9/27/2026"))1920 s.keys("1450", "<tab>", "612.4", "<enter>", "<up>", "<shift+right>", "<ctrl+shift+4>")21 s.waitForLine(gridRow1+4, numRow(5, "$1,450.00", "$612.40"))22 s.waitFor("Currency format for A5:B5")2324 // Too wide next to a filled cell: #s, as in Sheets.25 s.keys("<ctrl+shift+5>", "<ctrl+b>")26 s.waitForLine(gridRow1+4, numRow(5, "#########", "61240.00%"))27 s.waitFor("Bold on for A5:B5")28 if !strings.Contains(s.html(), "font-weight:bold") {29 t.Errorf("no bold cells:\n%s", s.html())30 }31}3233func TestFormatsSurviveSaveAndReopen(t *testing.T) {34 t.Parallel()35 dir := t.TempDir()36 s := start(t, dir)37 s.keys("1450", "<enter>", "<up>", "<ctrl+shift+1>", "<ctrl+i>")38 s.waitForLine(gridRow1, numRow(1, "1,450.00"))39 s.keys("<ctrl+s>", "formats", "<enter>")40 s.eventually("saved", func() bool { return s.title() == "012 - formats.012" })41 s.keys("<ctrl+q>")42 s.waitExit()4344 r := start(t, dir, "formats.012")45 r.waitForLine(gridRow1, numRow(1, "1,450.00"))46 if !strings.Contains(r.html(), "font-style:italic") {47 t.Errorf("italic lost after reopening:\n%s", r.html())48 }49}5051// A column's format travels when the column is copied, and formulas52// reading its blanks take it at once.53func TestColumnFormatTravelsWithCopy(t *testing.T) {54 t.Parallel()55 s := start(t, "")56 s.keys("5", "<enter>", "7", "<enter>", "<ctrl+home>", "<right>", "=C9*2", "<enter>")57 s.waitForLine(gridRow1, numRow(1, "5", "0"))58 s.keys("<ctrl+home>", "<ctrl+space>", "<ctrl+shift+4>", "<ctrl+c>")59 s.waitFor("Copied A:A")60 s.keys("<esc>", "<right>", "<right>", "<ctrl+v>")61 s.waitFor("Pasted 1 column at C:C")62 s.waitForLine(gridRow1, numRow(1, "$5.00", "$0.00", "$5.00"))63 s.keys("<esc>", "<down>", "<down>", "<down>", "<down>", "3", "<enter>")64 s.waitForLine(gridRow1+4, numRow(5, "", "", "$3.00"))65}