| | @@ -24,11 +24,11 @@ |
| 24 | 24 | expect(drawn).not.toContain('❯') |
| 25 | 25 | }) |
| 26 | 26 | |
| 27 | | - test('inline, a row moves the pointer and the body to it', async ($, on) => { |
| 27 | + test('inline, a row opens that file alone', async ($, on) => { |
| 28 | 28 | const world = Fixtures.inRepository(on, Fixtures.TWO_FILES) |
| 29 | 29 | |
| 30 | 30 | await $.session.start(Fixtures.SESSION) |
| 31 | | - await $.command.run(Fixtures.DIFF) |
| 31 | + await $.command.run(Fixtures.DIALOG_DIFF) |
| 32 | 32 | await world.clock.advance(Fixtures.SETTLE_MS) |
| 33 | 33 | await $.ui.render(Fixtures.INLINE_PANE) |
| 34 | 34 | |
| | @@ -38,27 +38,59 @@ |
| 38 | 38 | |
| 39 | 39 | const drawn = Fixtures.textOf(await $.ui.render(Fixtures.INLINE_PANE)) |
| 40 | 40 | |
| 41 | | - expect(drawn).toContain('\u276f lib.ts') |
| 42 | 41 | expect(drawn).toContain('+export const c = 2') |
| 43 | 42 | expect(drawn).not.toContain('+const a = 2') |
| 43 | + expect(drawn).not.toContain('app.ts') |
| 44 | + expect(drawn).toContain('\u2191/\u2193 to scroll \u00b7 Esc to back') |
| 44 | 45 | }) |
| 45 | 46 | |
| 46 | | - test('past eight files the docked list counts the rest', async ($, on) => { |
| 47 | + test('docked, a wheel tick moves the body, not the list', async ($, on) => { |
| 47 | 48 | const world = Fixtures.inRepository(on, Fixtures.MANY_FILES) |
| 48 | 49 | |
| 49 | 50 | await $.session.start(Fixtures.SESSION) |
| 50 | 51 | await $.command.run(Fixtures.DIFF) |
| 51 | 52 | await world.clock.advance(Fixtures.SETTLE_MS) |
| 52 | 53 | |
| 54 | + const before = Fixtures.textOf(await $.ui.render(Fixtures.PANE)) |
| 55 | + |
| 56 | + expect(before, 'listed, and named over its body').toContain('file0.ts') |
| 57 | + expect(before.split('file0.ts')).toHaveLength(3) |
| 58 | + |
| 59 | + expect(await $.ui.scroll(Fixtures.WHEEL_TICK)).toEqual({}) |
| 60 | + |
| 61 | + const after = Fixtures.textOf(await $.ui.render(Fixtures.PANE)) |
| 62 | + |
| 63 | + expect(after.split('file0.ts'), 'its name row scrolled away').toHaveLength( |
| 64 | + 2, |
| 65 | + ) |
| 66 | + |
| 67 | + expect(after).toContain('-const v = 0') |
| 68 | + expect(after).toContain('10 files changed +10 -10') |
| 69 | + }) |
| 70 | + |
| 71 | + test('past eight files the docked list scrolls by key', async ($, on) => { |
| 72 | + const world = Fixtures.inRepository(on, Fixtures.MANY_FILES) |
| 73 | + |
| 74 | + await $.session.start(Fixtures.SESSION) |
| 75 | + await $.command.run(Fixtures.DIFF) |
| 76 | + await world.clock.advance(Fixtures.SETTLE_MS) |
| 77 | + |
| 53 | 78 | const drawn = Fixtures.textOf(await $.ui.render(Fixtures.PANE)) |
| 54 | 79 | |
| 55 | 80 | expect(drawn).toContain('10 files changed +10 -10') |
| 56 | 81 | expect(drawn).toContain('file7.ts') |
| 57 | | - expect(drawn).toContain('↓ 2 more below') |
| 82 | + expect(drawn).toContain('\u2193 2 more below (opt+\u2193 to scroll)') |
| 83 | + expect(drawn).not.toContain('file8.ts') |
| 58 | 84 | |
| 59 | | - expect(drawn.indexOf('↓ 2 more below')).toBeLessThan( |
| 60 | | - drawn.indexOf('file8.ts'), |
| 61 | | - ) |
| 85 | + expect(await $.ui.press({ plugin: 'diff', key: 'list-down' })).toEqual({ |
| 86 | + element: 'list-down', |
| 87 | + }) |
| 88 | + |
| 89 | + const scrolled = Fixtures.textOf(await $.ui.render(Fixtures.PANE)) |
| 90 | + |
| 91 | + expect(scrolled).toContain('\u2191 1 more above') |
| 92 | + expect(scrolled).toContain('file8.ts') |
| 93 | + expect(scrolled).toContain('\u2193 1 more below') |
| 62 | 94 | }) |
| 63 | 95 | |
| 64 | 96 | test('a rename lists as git prints it, and reads no body', async ($, on) => { |
| | @@ -79,21 +111,27 @@ |
| 79 | 111 | ).toEqual([]) |
| 80 | 112 | }) |
| 81 | 113 | |
| 82 | | - test('inline on a wide terminal, the rows round one file', async ($, on) => { |
| 114 | + test('inline, the dialog lists every file and its keys', async ($, on) => { |
| 83 | 115 | const world = Fixtures.inRepository(on, Fixtures.TWO_FILES) |
| 84 | 116 | |
| 85 | 117 | await $.session.start(Fixtures.SESSION) |
| 86 | | - await $.command.run(Fixtures.DIFF) |
| 118 | + await $.command.run(Fixtures.DIALOG_DIFF) |
| 87 | 119 | await world.clock.advance(Fixtures.SETTLE_MS) |
| 88 | 120 | |
| 89 | 121 | const drawn = Fixtures.textOf(await $.ui.render(Fixtures.INLINE_PANE)) |
| 90 | 122 | |
| 91 | | - expect(drawn).toContain('❯ app.ts') |
| 92 | | - expect(drawn).toContain('+const a = 2') |
| 93 | | - expect(drawn).not.toContain('+export const c = 2') |
| 123 | + expect(drawn).toContain('Uncommitted changes (git diff HEAD)') |
| 124 | + expect(drawn).toContain('2 files changed +3 -1') |
| 125 | + expect(drawn).toContain(' app.ts') |
| 126 | + expect(drawn).toContain(' lib.ts') |
| 127 | + expect(drawn).not.toContain('+const a = 2') |
| 128 | + |
| 129 | + expect(drawn).toContain( |
| 130 | + '\u2191/\u2193 to select \u00b7 Enter to view \u00b7 Esc to close', |
| 131 | + ) |
| 94 | 132 | }) |
| 95 | 133 | |
| 96 | | - test('inline on a narrow terminal, the resize line', async ($, on) => { |
| 134 | + test('narrow under the fullscreen layout, the resize line', async ($, on) => { |
| 97 | 135 | const world = Fixtures.inRepository(on, Fixtures.TWO_FILES) |
| 98 | 136 | |
| 99 | 137 | await $.session.start(Fixtures.SESSION) |
| | @@ -106,4 +144,40 @@ |
| 106 | 144 | 'Resize your terminal to at least 110 columns to show the diff panel', |
| 107 | 145 | ) |
| 108 | 146 | }) |
| 147 | + |
| 148 | + test('off fullscreen, forty files list five at a time', async ($, on) => { |
| 149 | + const world = Fixtures.inRepository(on, Fixtures.MANY_FILES) |
| 150 | + |
| 151 | + await $.session.start(Fixtures.SESSION) |
| 152 | + await $.command.run(Fixtures.DIALOG_DIFF) |
| 153 | + await world.clock.advance(Fixtures.SETTLE_MS) |
| 154 | + |
| 155 | + const drawn = Fixtures.textOf(await $.ui.render(Fixtures.INLINE_PANE)) |
| 156 | + |
| 157 | + expect(drawn).toContain(' file4.ts') |
| 158 | + expect(drawn).not.toContain('file5.ts') |
| 159 | + expect(drawn).toContain(' \u2193 5 more files') |
| 160 | + |
| 161 | + expect(await $.ui.press({ plugin: 'diff', key: 'files-down' })).toEqual({ |
| 162 | + element: 'files-down', |
| 163 | + }) |
| 164 | + |
| 165 | + const paged = Fixtures.textOf(await $.ui.render(Fixtures.INLINE_PANE)) |
| 166 | + |
| 167 | + expect(paged).toContain(' \u2191 5 more files') |
| 168 | + expect(paged).toContain(' file9.ts') |
| 169 | + expect(paged).not.toContain('file4.ts') |
| 170 | + }) |
| 171 | + |
| 172 | + test('off fullscreen, the dialog draws at any width', async ($, on) => { |
| 173 | + const world = Fixtures.inRepository(on, Fixtures.TWO_FILES) |
| 174 | + |
| 175 | + await $.session.start(Fixtures.SESSION) |
| 176 | + await $.command.run(Fixtures.DIALOG_DIFF) |
| 177 | + await world.clock.advance(Fixtures.SETTLE_MS) |
| 178 | + |
| 179 | + expect( |
| 180 | + Fixtures.textOf(await $.ui.render(Fixtures.NARROW_INLINE_PANE)), |
| 181 | + ).toContain('Uncommitted changes (git diff HEAD)') |
| 182 | + }) |
| 109 | 183 | }) |