const exploreCli = require('..');
const Process = require('./Process');

const setup = (offset = 0) => {
    const proc = new Process({ rows: 6 });
    exploreCli({ 
        offset,
        data: [
            'line 1',
            'line 2',
            'line 3',
            'line 4',
            'line 5',
            'line 6',
            'line 7',
            'line 8',
            'line 9',
        ]
    }, proc);
    return proc;
};

describe('scrolling', () => {
    test('should display initial state (no scrolling)', () => {
        const proc = setup();
        expect(proc.screen()).toEqual([
            '[                             ',
            '  "line 1",                   ',
            '  "line 2",                   ',
            '  "line 3",                   ',
            '  "line 4",                   ',
            '  "line 5",                   ',
        ]);
    });

    test('should be able to scroll down one line', () => {
        const proc = setup();
        proc.press({ ctrl: false, shift: false, name: 'j' });
        expect(proc.screen()).toEqual([
            '  "line 1",                   ',
            '  "line 2",                   ',
            '  "line 3",                   ',
            '  "line 4",                   ',
            '  "line 5",                   ',
            '  "line 6",                   ',
        ]);
    });

    test('should be able to scroll down half a screen', () => {
        const proc = setup();
        proc.press({ ctrl: true, shift: false, name: 'd' });
        expect(proc.screen()).toEqual([
            '  "line 3",                   ',
            '  "line 4",                   ',
            '  "line 5",                   ',
            '  "line 6",                   ',
            '  "line 7",                   ',
            '  "line 8",                   ',
        ]);
    });

    test('should be able to scroll up one line', () => {
        const proc = setup(3);
        proc.press({ ctrl: false, shift: false, name: 'k' });
        expect(proc.screen()).toEqual([
            '  "line 2",                   ',
            '  "line 3",                   ',
            '  "line 4",                   ',
            '  "line 5",                   ',
            '  "line 6",                   ',
            '  "line 7",                   ',
        ]);
    });

    test('should be able to scroll up half a screen', () => {
        const proc = setup(3);
        proc.press({ ctrl: true, shift: false, name: 'u' });
        expect(proc.screen()).toEqual([
            '[                             ',
            '  "line 1",                   ',
            '  "line 2",                   ',
            '  "line 3",                   ',
            '  "line 4",                   ',
            '  "line 5",                   ',
        ]);
    });

    test('should not be able to scroll before the first line', () => {
        const proc = setup();
        proc.press({ ctrl: true, shift: false, name: 'u' });
        expect(proc.screen()).toEqual([
            '[                             ',
            '  "line 1",                   ',
            '  "line 2",                   ',
            '  "line 3",                   ',
            '  "line 4",                   ',
            '  "line 5",                   ',
        ]);
    });

    test('should not be able to scroll past the last line', () => {
        const proc = setup(10);
        proc.press({ ctrl: true, shift: false, name: 'd' });
        expect(proc.screen()).toEqual([
            ']                             ',
            '                              ',
            '                              ',
            '                              ',
            '                              ',
            '                              ',
        ]);
    });
});
@@ -905,34 +905,27 @@
   test('
+%5Bi%5D 
 should 
-be able to 
 scroll d
@@ -1386,33 +1386,31 @@
   test('
-should be able to
+%5Bctrl-d%5D should
  scroll 
@@ -1876,34 +1876,27 @@
   test('
+%5Bk%5D 
 should 
-be able to 
 scroll u
@@ -2360,25 +2360,23 @@
 st('
-should be able to
+%5Bctrl-u%5D should
  scr
@@ -2851,33 +2851,37 @@
 ('should not be 
-a
+possi
 ble to scroll be
@@ -3362,17 +3362,21 @@
  not be 
-a
+possi
 ble to s

Change scrolling spec wording