The tree was formatted with an older gofmt; go1.27's gofmt additionally wants: EOF exactly one newline (no trailing blank lines), imports sorted alphabetically within a block, mixed-precedence binary expressions re-spaced for grouping ((a+b)/c), single-field composite literals un-aligned, adjacent one-line method signatures aligned, and one-line bodies containing a compound statement expanded. Applied repo-wide (31 files under internal/); pure formatting, no semantic changes — build and the full test suite pass.
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package editor
|
|
|
|
import (
|
|
"pad/internal/ui"
|
|
"testing"
|
|
)
|
|
|
|
func TestEditorLayout_Filename(t *testing.T) {
|
|
// Setup: Reset state
|
|
TheState = NewState()
|
|
|
|
// Set a filename
|
|
expectedFilename := "test.txt"
|
|
TheState.Editor.Filename = expectedFilename
|
|
|
|
// Run layout
|
|
screenWidth := ui.Dp(400)
|
|
screenHeight := ui.Dp(800)
|
|
elements := EditorLayout(screenWidth, screenHeight, false)
|
|
|
|
// Find top bar (assuming it's the first container element)
|
|
topBar := elements[0].(ui.Container)
|
|
|
|
// Find the filename label in the top bar (the back icon precedes it).
|
|
var filenameLabel ui.Label
|
|
for _, c := range topBar.Children {
|
|
if l, ok := c.(ui.Label); ok {
|
|
filenameLabel = l
|
|
break
|
|
}
|
|
}
|
|
if filenameLabel.Text != expectedFilename {
|
|
t.Errorf("expected filename %q, got %q", expectedFilename, filenameLabel.Text)
|
|
}
|
|
}
|
|
|
|
func TestEditorLayout_DefaultFilename(t *testing.T) {
|
|
// Setup: Reset state
|
|
TheState = NewState()
|
|
|
|
// Filename is empty
|
|
TheState.Editor.Filename = ""
|
|
|
|
// Run layout
|
|
screenWidth := ui.Dp(400)
|
|
screenHeight := ui.Dp(800)
|
|
elements := EditorLayout(screenWidth, screenHeight, false)
|
|
|
|
// Find top bar (assuming it's the first container element)
|
|
topBar := elements[0].(ui.Container)
|
|
|
|
// Find the filename label in the top bar (the back icon precedes it).
|
|
var filenameLabel ui.Label
|
|
for _, c := range topBar.Children {
|
|
if l, ok := c.(ui.Label); ok {
|
|
filenameLabel = l
|
|
break
|
|
}
|
|
}
|
|
expectedDefault := "untitled.txt"
|
|
if filenameLabel.Text != expectedDefault {
|
|
t.Errorf("expected default filename %q, got %q", expectedDefault, filenameLabel.Text)
|
|
}
|
|
}
|