Skip to content

Commit dca499e

Browse files
committed
Merge pull request #106 from facebook/addCommandModeTest
Add command mode test
2 parents fc59304 + 202e8a2 commit dca499e

3 files changed

Lines changed: 44 additions & 3 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
Oh no! You already provided a command so you cannot enter command mode.
12+
The command you provided was " 'git add'"
13+
Press any key to go back to selecting files.
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
________________________________________________________________________________
30+
[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mod

src/__tests__/screenTestRunner.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ def getRowsFromScreenRun(
3636
charInputs,
3737
screenConfig={},
3838
printScreen=True,
39-
pastScreen=None):
39+
pastScreen=None,
40+
args=[]):
41+
4042
lineObjs = getLineObjsFromFile(inputFile)
4143
screen = ScreenForTest(
4244
charInputs,
4345
maxX=screenConfig.get('maxX', 80),
4446
maxY=screenConfig.get('maxY', 30),
4547
)
46-
# mock our flags with an empty command line for now
47-
flags = ScreenFlags.initFromArgs([])
48+
# mock our flags with the passed arg list
49+
flags = ScreenFlags.initFromArgs(args)
4850
try:
4951
choose.doProgram(screen, flags, CursesForTest(), lineObjs)
5052
except StopIteration:

src/__tests__/testScreen.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
'input': 'absoluteGitDiff.txt',
3838
'inputs': ['f', 'j', 'f', 'c'],
3939
'pastScreen': 1
40+
}, {
41+
'name': 'selectCommandWithPassedCommand',
42+
'input': 'absoluteGitDiff.txt',
43+
# the last key "a" is so we quit from command mode
44+
# after seeing the warning
45+
'inputs': ['f', 'c', 'a'],
46+
'pastScreen': 1,
47+
'args': ["-c 'git add'"]
4048
}]
4149

4250

@@ -59,6 +67,7 @@ def testScreenInputs(self):
5967
screenConfig=testCase.get('screenConfig', {}),
6068
printScreen=False,
6169
pastScreen=testCase.get('pastScreen', None),
70+
args=testCase.get('args', [])
6271
)
6372
self.compareToExpected(testName, actualLines)
6473
print('Tested %s ' % testName)

0 commit comments

Comments
 (0)