forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputHistory.unit.test.ts
More file actions
71 lines (69 loc) · 3.09 KB
/
inputHistory.unit.test.ts
File metadata and controls
71 lines (69 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { assert } from 'chai';
import { InputHistory } from '../../datascience-ui/interactive-common/inputHistory';
suite('DataScience InputHistory', () => {
test('input history', async () => {
let history = new InputHistory();
history.add('1', true);
history.add('2', true);
history.add('3', true);
history.add('4', true);
assert.equal(history.completeDown('5'), '5');
history.add('5', true);
assert.equal(history.completeUp(''), '5');
history.add('5', false);
assert.equal(history.completeUp('5'), '5');
assert.equal(history.completeUp('4'), '4');
assert.equal(history.completeUp('2'), '3');
assert.equal(history.completeUp('1'), '2');
assert.equal(history.completeUp(''), '1');
// Add should reset position.
history.add('6', true);
assert.equal(history.completeUp(''), '6');
assert.equal(history.completeUp(''), '5');
assert.equal(history.completeUp(''), '4');
assert.equal(history.completeUp(''), '3');
assert.equal(history.completeUp(''), '2');
assert.equal(history.completeUp(''), '1');
history = new InputHistory();
history.add('1', true);
history.add('2', true);
history.add('3', true);
history.add('4', true);
assert.equal(history.completeDown('5'), '5');
assert.equal(history.completeDown(''), '');
assert.equal(history.completeUp('1'), '4');
assert.equal(history.completeDown('4'), '4');
assert.equal(history.completeDown('4'), '4');
assert.equal(history.completeUp('1'), '3');
assert.equal(history.completeUp('4'), '2');
assert.equal(history.completeDown('3'), '3');
assert.equal(history.completeDown(''), '4');
assert.equal(history.completeUp(''), '3');
assert.equal(history.completeUp(''), '2');
assert.equal(history.completeUp(''), '1');
assert.equal(history.completeUp(''), '');
assert.equal(history.completeUp('1'), '1');
assert.equal(history.completeDown('1'), '2');
assert.equal(history.completeDown('2'), '3');
assert.equal(history.completeDown('3'), '4');
assert.equal(history.completeDown(''), '');
history.add('5', true);
assert.equal(history.completeUp('1'), '5');
assert.equal(history.completeUp('1'), '4');
assert.equal(history.completeUp('1'), '3');
history.add('3', false);
assert.equal(history.completeUp('1'), '3');
assert.equal(history.completeUp('1'), '2');
assert.equal(history.completeUp('1'), '1');
assert.equal(history.completeDown('1'), '2');
assert.equal(history.completeUp('1'), '1');
assert.equal(history.completeDown('1'), '2');
assert.equal(history.completeDown('1'), '3');
assert.equal(history.completeDown('1'), '4');
assert.equal(history.completeDown('1'), '5');
assert.equal(history.completeDown('1'), '3');
});
});