1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-23 21:51:07 +02:00
lazygit/pkg/integration/tests/diff/ignore_whitespace.go
2023-04-30 13:19:53 +10:00

65 lines
1.8 KiB
Go

package diff
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var (
initialFileContent = "first-line\nold-second-line\nthird-line\n"
// We're indenting each line and modifying the second line
updatedFileContent = " first-line\n new-second-line\n third-line\n"
)
var IgnoreWhitespace = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Toggle whitespace in the diff",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("myfile", initialFileContent)
shell.Commit("initial commit")
shell.UpdateFile("myfile", updatedFileContent)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Main().ContainsLines(
Contains(`-first-line`),
Contains(`-old-second-line`),
Contains(`-third-line`),
Contains(`+ first-line`),
Contains(`+ new-second-line`),
Contains(`+ third-line`),
)
t.Views().Files().
IsFocused().
Press(keys.Universal.ToggleWhitespaceInDiffView)
t.ExpectToast(Equals("Whitespace will be ignored in the diff view"))
// lines with only whitespace changes are ignored (first and third lines)
t.Views().Main().ContainsLines(
Contains(` first-line`),
Contains(`-old-second-line`),
Contains(`+ new-second-line`),
Contains(` third-line`),
)
// when toggling again it goes back to showing whitespace
t.Views().Files().
IsFocused().
Press(keys.Universal.ToggleWhitespaceInDiffView)
t.ExpectToast(Equals("Whitespace will be shown in the diff view"))
t.Views().Main().ContainsLines(
Contains(`-first-line`),
Contains(`-old-second-line`),
Contains(`-third-line`),
Contains(`+ first-line`),
Contains(`+ new-second-line`),
Contains(`+ third-line`),
)
},
})