@@ -3,14 +3,13 @@ import React from 'react';
3
3
import { shallow } from 'enzyme' ;
4
4
import _ from 'react-bootstrap-table-next/src/utils' ;
5
5
import dataOperator from 'react-bootstrap-table-next/src/store/operators' ;
6
- import BootstrapTable from 'react-bootstrap-table-next/src/bootstrap-table' ;
7
6
8
7
import {
9
8
CLICK_TO_CELL_EDIT ,
10
9
DBCLICK_TO_CELL_EDIT ,
11
10
DELAY_FOR_DBCLICK
12
11
} from '../src/const' ;
13
- import createCellEditContext from '../src/context' ;
12
+ import createCellEditContext , { Consumer } from '../src/context' ;
14
13
import cellEditFactory from '../index' ;
15
14
16
15
describe ( 'CellEditContext' , ( ) => {
@@ -42,14 +41,7 @@ describe('CellEditContext', () => {
42
41
43
42
const defaultSelectRow = undefined ;
44
43
45
- const mockBase = jest . fn ( ( props => (
46
- < BootstrapTable
47
- data = { data }
48
- columns = { columns }
49
- keyField = { keyField }
50
- { ...props }
51
- />
52
- ) ) ) ;
44
+ const mockBase = jest . fn ( ( ( ) => null ) ) ;
53
45
54
46
const handleCellChange = jest . fn ( ) ;
55
47
@@ -75,11 +67,11 @@ describe('CellEditContext', () => {
75
67
selectRow = { selectRow }
76
68
data = { data }
77
69
>
78
- < CellEditContext . Consumer >
70
+ < Consumer >
79
71
{
80
72
cellEditProps => mockBase ( cellEditProps )
81
73
}
82
- </ CellEditContext . Consumer >
74
+ </ Consumer >
83
75
</ CellEditContext . Provider >
84
76
) ;
85
77
}
@@ -94,10 +86,6 @@ describe('CellEditContext', () => {
94
86
expect ( CellEditContext . Provider ) . toBeDefined ( ) ;
95
87
} ) ;
96
88
97
- it ( 'should have correct Consumer property after calling createCellEditContext' , ( ) => {
98
- expect ( CellEditContext . Consumer ) . toBeDefined ( ) ;
99
- } ) ;
100
-
101
89
it ( 'should have correct state.ridx' , ( ) => {
102
90
expect ( wrapper . state ( ) . ridx ) . toBeNull ( ) ;
103
91
} ) ;
@@ -113,14 +101,11 @@ describe('CellEditContext', () => {
113
101
it ( 'should pass correct cell editing props to children element' , ( ) => {
114
102
expect ( wrapper . length ) . toBe ( 1 ) ;
115
103
expect ( JSON . stringify ( mockBase . mock . calls [ 0 ] ) ) . toEqual ( JSON . stringify ( [ {
116
- cellEdit : {
117
- ...defaultCellEdit ,
118
- CLICK_TO_CELL_EDIT ,
119
- DBCLICK_TO_CELL_EDIT ,
120
- DELAY_FOR_DBCLICK ,
121
- ...wrapper . state ( ) ,
122
- nonEditableRows : [ ]
123
- }
104
+ ...defaultCellEdit ,
105
+ DBCLICK_TO_CELL_EDIT ,
106
+ DELAY_FOR_DBCLICK ,
107
+ ...wrapper . state ( ) ,
108
+ nonEditableRows : [ ]
124
109
} ] ) ) ;
125
110
} ) ;
126
111
} ) ;
0 commit comments