Skip to content

Commit 2689ddc

Browse files
committed
Test count value in command decoration
This adds tests to ensure the appropriate functioning of the count option of the _nvim_rpc_spec when using the command decorator.
1 parent 8ed548c commit 2689ddc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/test_decorators.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from nose.tools import with_setup, eq_ as eq, ok_ as ok
2+
3+
from neovim.plugin.decorators import command
4+
5+
6+
def test_command_count():
7+
def function():
8+
"A dummy function to decorate."
9+
return
10+
11+
# ensure absence with default value of None
12+
decorated = command('test')(function)
13+
ok('count' not in decorated._nvim_rpc_spec['opts'])
14+
15+
# ensure absence with explicit value of None
16+
count_value = None
17+
decorated = command('test', count=count_value)(function)
18+
ok('count' not in decorated._nvim_rpc_spec['opts'])
19+
20+
# Test presesence with value of 0
21+
count_value = 0
22+
decorated = command('test', count=count_value)(function)
23+
ok('count' in decorated._nvim_rpc_spec['opts'])
24+
eq(decorated._nvim_rpc_spec['opts']['count'], count_value)
25+
26+
# Test presence with value of 1
27+
count_value = 1
28+
decorated = command('test', count=count_value)(function)
29+
ok('count' in decorated._nvim_rpc_spec['opts'])
30+
eq(decorated._nvim_rpc_spec['opts']['count'], count_value)

0 commit comments

Comments
 (0)