| 1 | using CascadeIDE.Features.UiChrome; |
| 2 | using CascadeIDE.IdeDisplay.CommandPalette; |
| 3 | using CascadeIDE.Services; |
| 4 | using CascadeIDE.ViewModels; |
| 5 | using Xunit; |
| 6 | |
| 7 | namespace CascadeIDE.Tests; |
| 8 | |
| 9 | public sealed class CommandPaletteSurfaceCompositorTests |
| 10 | { |
| 11 | [Fact] |
| 12 | public void Compose_EmptyRows_ReturnsEmptySnapshot() |
| 13 | { |
| 14 | var sut = new CommandPaletteSurfaceCompositor(); |
| 15 | var intent = new CommandPaletteSurfaceIntent("git", 0, []); |
| 16 | var snapshot = sut.Compose(intent); |
| 17 | |
| 18 | Assert.Equal("git", snapshot.Query); |
| 19 | Assert.Equal(-1, snapshot.SelectedIndex); |
| 20 | Assert.Empty(snapshot.Items); |
| 21 | } |
| 22 | |
| 23 | [Fact] |
| 24 | public void Compose_MapsRowsAndClampsSelection() |
| 25 | { |
| 26 | var sut = new CommandPaletteSurfaceCompositor(); |
| 27 | var entry = IdeCommandPaletteCatalog.All[0]; |
| 28 | var rows = new List<IdeCommandPaletteRowViewModel> |
| 29 | { |
| 30 | new(entry, hotkeyHint: "Ctrl+Q", currentFamily: UiModeFamily.Balanced), |
| 31 | new("Ничего не найдено", "Подсказка"), |
| 32 | }; |
| 33 | |
| 34 | var intent = new CommandPaletteSurfaceIntent("", 99, rows); |
| 35 | var snapshot = sut.Compose(intent); |
| 36 | |
| 37 | Assert.Equal(1, snapshot.SelectedIndex); |
| 38 | Assert.Equal(2, snapshot.Items.Count); |
| 39 | Assert.Equal(rows[0].Title, snapshot.Items[0].Title); |
| 40 | Assert.Equal(rows[0].Subtitle, snapshot.Items[0].Subtitle); |
| 41 | Assert.Equal(rows[0].HotkeyHint, snapshot.Items[0].HotkeyHint); |
| 42 | } |
| 43 | } |
| 44 | |