Skip to content

Commit 4c4f633

Browse files
committed
add selection test cases
Signed-off-by: Itay Dafna <[email protected]>
1 parent 933e992 commit 4c4f633

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_datagrid.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import pytest
2+
import pandas as pd
3+
from ipydatagrid import DataGrid
4+
5+
6+
def test_selections():
7+
df = pd.DataFrame(data={"A":[1,2,3],"B":[4,5,6]})
8+
datagrid = DataGrid(df, selection_mode="cell", layout={"height":"100px"}, editable=True)
9+
datagrid.select(1,0,2,1) # Select 1A to 2B
10+
11+
assert datagrid.selections == [{'r1': 1, 'c1': 0, 'r2': 2, 'c2': 1}]
12+
13+
def test_selection_clearing():
14+
df = pd.DataFrame(data={"A":[1,2,3],"B":[4,5,6]})
15+
datagrid = DataGrid(df, selection_mode="cell", layout={"height":"100px"}, editable=True)
16+
datagrid.select(1,0,2,1) # Select 1A to 2B
17+
datagrid.clear_selection()
18+
assert datagrid.selections == []

0 commit comments

Comments
 (0)