Coverage for tests/test_fzf.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-03-24 11:53 -0300

1# test_fzf.py 

2 

3import pytest 

4from pyselector.menus.fzf import Fzf 

5 

6 

7@pytest.fixture 

8def fzf() -> Fzf: 

9 return Fzf() 

10 

11 

12def test_check_command(fzf) -> None: 

13 assert "fzf" in fzf.command 

14 

15 

16def test_build_command(fzf) -> None: 

17 alt_n = fzf.keybind.add( 

18 key="alt-n", 

19 description="do something...", 

20 callback=lambda: None, 

21 hidden=False, 

22 ) 

23 

24 args = fzf._build_command( 

25 case_sensitive=True, 

26 multi_select=False, 

27 prompt="Testing>", 

28 mesg="Testing...", 

29 cycle=True, 

30 preview=True, 

31 ) 

32 

33 assert "--prompt" in args 

34 assert "--header" in args 

35 assert "--cycle" in args 

36 assert f"--bind={alt_n.bind}:" in args 

37 assert "--no-preview" not in args 

38 

39 with pytest.warns(UserWarning): 

40 other_args = fzf._build_command( 

41 case_sensitive=True, 

42 multi_select=True, 

43 prompt="Testing>", 

44 preview=False, 

45 invalid_arg=True, 

46 ) 

47 

48 assert "--no-preview" in other_args 

49 assert "--multi" in other_args