Coverage for src/tests/test_tap.py: 100%

1 import remedapy as R

2 from tests.util import Spy

3

4

5 class TestTap:

6 def test_data_first(self):

7 # R.tap(value, fn);

8 spy = Spy()

9 assert R.tap('foo', spy) == 'foo'

10 assert spy.calls == [('foo',)]

11

12 def test_data_last(self):

13 # R.tap(fn)(value);

14 spy = Spy()

15

16 def bigger_than_zero(n: int) -> bool:

17 return n > 0

18

19 def times_two(n: int) -> int:

20 return n * 2

21

22 assert R.pipe(

23 [-5, -1, 2, 3],

24 R.filter(bigger_than_zero),

25 list,

26 R.tap(spy),

27 R.map(times_two),

28 list,

29 ) == [4, 6]

30 assert spy.calls == [([2, 3],)]