| @@ 248-373 (lines=126) @@ | ||
| 245 | ||
| 246 | }); |
|
| 247 | ||
| 248 | it('Should map over a column when dataIndex has changed', () => { |
|
| 249 | ||
| 250 | const storageCoumns = [ |
|
| 251 | { |
|
| 252 | sortDirection: null, |
|
| 253 | className: 'additional-class', |
|
| 254 | width: '40%', |
|
| 255 | dataIndex: ['person', 'name'], |
|
| 256 | hidden: true, |
|
| 257 | name: 'Name', |
|
| 258 | expandable: true, |
|
| 259 | sortable: true, |
|
| 260 | id: 'TmFtZWdyaWQtY29sdW1u' |
|
| 261 | }, |
|
| 262 | { |
|
| 263 | name: 'Phone Number', |
|
| 264 | dataIndex: 'Phone Number', |
|
| 265 | sortable: true, |
|
| 266 | className: 'additional-class', |
|
| 267 | id: 'UGhvbmUgTnVtYmVyZ3JpZC1jb2x1bW4=', |
|
| 268 | sortDirection: null |
|
| 269 | }, |
|
| 270 | { |
|
| 271 | name: 'Email', |
|
| 272 | dataIndex: 'Email', |
|
| 273 | sortable: true, |
|
| 274 | className: 'additional-class', |
|
| 275 | defaultSortDirection: 'descend', |
|
| 276 | id: 'RW1haWxncmlkLWNvbHVtbg==', |
|
| 277 | sortDirection: null |
|
| 278 | }, |
|
| 279 | { |
|
| 280 | name: 'Address', |
|
| 281 | dataIndex: 'Address', |
|
| 282 | sortable: true, |
|
| 283 | className: 'additional-class', |
|
| 284 | id: 'QWRkcmVzc2dyaWQtY29sdW1u', |
|
| 285 | sortDirection: 'DESC' |
|
| 286 | } |
|
| 287 | ]; |
|
| 288 | ||
| 289 | const propColumns = [ |
|
| 290 | { |
|
| 291 | name: 'Phone Number', |
|
| 292 | dataIndex: 'Phone Number New', |
|
| 293 | sortable: true, |
|
| 294 | className: 'additional-class' |
|
| 295 | }, |
|
| 296 | { |
|
| 297 | name: 'New Column', |
|
| 298 | dataIndex: 'newColumn' |
|
| 299 | }, |
|
| 300 | { |
|
| 301 | name: 'New Column Again', |
|
| 302 | dataIndex: ['new', 'column'] |
|
| 303 | }, |
|
| 304 | { |
|
| 305 | className: 'additional-class', |
|
| 306 | width: '45%', |
|
| 307 | dataIndex: ['person', 'name'], |
|
| 308 | hidden: false, |
|
| 309 | name: 'Name', |
|
| 310 | expandable: true, |
|
| 311 | sortable: true, |
|
| 312 | renderer: () => {} |
|
| 313 | }, |
|
| 314 | { |
|
| 315 | name: 'Email', |
|
| 316 | dataIndex: 'Email', |
|
| 317 | sortable: true, |
|
| 318 | className: 'additional-class', |
|
| 319 | defaultSortDirection: 'descend' |
|
| 320 | }, |
|
| 321 | { |
|
| 322 | name: 'Address', |
|
| 323 | dataIndex: 'Address', |
|
| 324 | sortable: true, |
|
| 325 | className: 'additional-class' |
|
| 326 | } |
|
| 327 | ]; |
|
| 328 | ||
| 329 | const result = [ |
|
| 330 | { |
|
| 331 | name: 'Phone Number', |
|
| 332 | dataIndex: 'Phone Number New', |
|
| 333 | sortable: true, |
|
| 334 | className: 'additional-class' |
|
| 335 | }, |
|
| 336 | { |
|
| 337 | name: 'New Column', |
|
| 338 | dataIndex: 'newColumn' |
|
| 339 | }, |
|
| 340 | { |
|
| 341 | name: 'New Column Again', |
|
| 342 | dataIndex: ['new', 'column'] |
|
| 343 | }, |
|
| 344 | { |
|
| 345 | className: 'additional-class', |
|
| 346 | width: '40%', |
|
| 347 | dataIndex: ['person', 'name'], |
|
| 348 | hidden: true, |
|
| 349 | name: 'Name', |
|
| 350 | expandable: true, |
|
| 351 | sortable: true, |
|
| 352 | renderer: () => {} |
|
| 353 | }, |
|
| 354 | { |
|
| 355 | name: 'Email', |
|
| 356 | dataIndex: 'Email', |
|
| 357 | sortable: true, |
|
| 358 | className: 'additional-class', |
|
| 359 | defaultSortDirection: 'descend' |
|
| 360 | }, |
|
| 361 | { |
|
| 362 | name: 'Address', |
|
| 363 | dataIndex: 'Address', |
|
| 364 | sortable: true, |
|
| 365 | className: 'additional-class' |
|
| 366 | } |
|
| 367 | ]; |
|
| 368 | ||
| 369 | expect( |
|
| 370 | getColumnsFromStorage(storageCoumns, propColumns) |
|
| 371 | ).toEqual(result); |
|
| 372 | ||
| 373 | }); |
|
| 374 | ||
| 375 | }); |
|
| 376 | ||
| @@ 121-246 (lines=126) @@ | ||
| 118 | ||
| 119 | }); |
|
| 120 | ||
| 121 | it('Should map over a missing column', () => { |
|
| 122 | ||
| 123 | const storageCoumns = [ |
|
| 124 | { |
|
| 125 | sortDirection: null, |
|
| 126 | className: 'additional-class', |
|
| 127 | width: '40%', |
|
| 128 | dataIndex: ['person', 'name'], |
|
| 129 | hidden: true, |
|
| 130 | name: 'Name', |
|
| 131 | expandable: true, |
|
| 132 | sortable: true, |
|
| 133 | id: 'TmFtZWdyaWQtY29sdW1u' |
|
| 134 | }, |
|
| 135 | { |
|
| 136 | name: 'Phone Number', |
|
| 137 | dataIndex: 'Phone Number', |
|
| 138 | sortable: true, |
|
| 139 | className: 'additional-class', |
|
| 140 | id: 'UGhvbmUgTnVtYmVyZ3JpZC1jb2x1bW4=', |
|
| 141 | sortDirection: null |
|
| 142 | }, |
|
| 143 | { |
|
| 144 | name: 'Email', |
|
| 145 | dataIndex: 'Email', |
|
| 146 | sortable: true, |
|
| 147 | className: 'additional-class', |
|
| 148 | defaultSortDirection: 'descend', |
|
| 149 | id: 'RW1haWxncmlkLWNvbHVtbg==', |
|
| 150 | sortDirection: null |
|
| 151 | }, |
|
| 152 | { |
|
| 153 | name: 'Address', |
|
| 154 | dataIndex: 'Address', |
|
| 155 | sortable: true, |
|
| 156 | className: 'additional-class', |
|
| 157 | id: 'QWRkcmVzc2dyaWQtY29sdW1u', |
|
| 158 | sortDirection: 'DESC' |
|
| 159 | } |
|
| 160 | ]; |
|
| 161 | ||
| 162 | const propColumns = [ |
|
| 163 | { |
|
| 164 | name: 'Phone Number', |
|
| 165 | dataIndex: 'Phone Number', |
|
| 166 | sortable: true, |
|
| 167 | className: 'additional-class' |
|
| 168 | }, |
|
| 169 | { |
|
| 170 | name: 'New Column', |
|
| 171 | dataIndex: 'newColumn' |
|
| 172 | }, |
|
| 173 | { |
|
| 174 | name: 'New Column Again', |
|
| 175 | dataIndex: ['new', 'column'] |
|
| 176 | }, |
|
| 177 | { |
|
| 178 | className: 'additional-class', |
|
| 179 | width: '45%', |
|
| 180 | dataIndex: ['person', 'name'], |
|
| 181 | hidden: false, |
|
| 182 | name: 'Name', |
|
| 183 | expandable: true, |
|
| 184 | sortable: true, |
|
| 185 | renderer: () => {} |
|
| 186 | }, |
|
| 187 | { |
|
| 188 | name: 'Email', |
|
| 189 | dataIndex: 'Email', |
|
| 190 | sortable: true, |
|
| 191 | className: 'additional-class', |
|
| 192 | defaultSortDirection: 'descend' |
|
| 193 | }, |
|
| 194 | { |
|
| 195 | name: 'Address', |
|
| 196 | dataIndex: 'Address', |
|
| 197 | sortable: true, |
|
| 198 | className: 'additional-class' |
|
| 199 | } |
|
| 200 | ]; |
|
| 201 | ||
| 202 | const result = [ |
|
| 203 | { |
|
| 204 | name: 'New Column', |
|
| 205 | dataIndex: 'newColumn' |
|
| 206 | }, |
|
| 207 | { |
|
| 208 | name: 'New Column Again', |
|
| 209 | dataIndex: ['new', 'column'] |
|
| 210 | }, |
|
| 211 | { |
|
| 212 | className: 'additional-class', |
|
| 213 | width: '40%', |
|
| 214 | dataIndex: ['person', 'name'], |
|
| 215 | hidden: true, |
|
| 216 | name: 'Name', |
|
| 217 | expandable: true, |
|
| 218 | sortable: true, |
|
| 219 | renderer: () => {} |
|
| 220 | }, |
|
| 221 | { |
|
| 222 | name: 'Phone Number', |
|
| 223 | dataIndex: 'Phone Number', |
|
| 224 | sortable: true, |
|
| 225 | className: 'additional-class' |
|
| 226 | }, |
|
| 227 | { |
|
| 228 | name: 'Email', |
|
| 229 | dataIndex: 'Email', |
|
| 230 | sortable: true, |
|
| 231 | className: 'additional-class', |
|
| 232 | defaultSortDirection: 'descend' |
|
| 233 | }, |
|
| 234 | { |
|
| 235 | name: 'Address', |
|
| 236 | dataIndex: 'Address', |
|
| 237 | sortable: true, |
|
| 238 | className: 'additional-class' |
|
| 239 | } |
|
| 240 | ]; |
|
| 241 | ||
| 242 | expect( |
|
| 243 | getColumnsFromStorage(storageCoumns, propColumns) |
|
| 244 | ).toEqual(result); |
|
| 245 | ||
| 246 | }); |
|
| 247 | ||
| 248 | it('Should map over a column when dataIndex has changed', () => { |
|
| 249 | ||
| @@ 10-119 (lines=110) @@ | ||
| 7 | ||
| 8 | describe('the getColumnsFromStorage utility', () => { |
|
| 9 | ||
| 10 | it('Should map width, order, and hidden only', () => { |
|
| 11 | ||
| 12 | const storageCoumns = [ |
|
| 13 | { |
|
| 14 | sortDirection: null, |
|
| 15 | className: 'additional-class', |
|
| 16 | width: '40%', |
|
| 17 | dataIndex: ['person', 'name'], |
|
| 18 | hidden: true, |
|
| 19 | name: 'Name', |
|
| 20 | expandable: true, |
|
| 21 | sortable: true, |
|
| 22 | id: 'TmFtZWdyaWQtY29sdW1u' |
|
| 23 | }, |
|
| 24 | { |
|
| 25 | name: 'Phone Number', |
|
| 26 | dataIndex: 'Phone Number', |
|
| 27 | sortable: true, |
|
| 28 | className: 'additional-class', |
|
| 29 | id: 'UGhvbmUgTnVtYmVyZ3JpZC1jb2x1bW4=', |
|
| 30 | sortDirection: null |
|
| 31 | }, |
|
| 32 | { |
|
| 33 | name: 'Email', |
|
| 34 | dataIndex: 'Email', |
|
| 35 | sortable: true, |
|
| 36 | className: 'additional-class', |
|
| 37 | defaultSortDirection: 'descend', |
|
| 38 | id: 'RW1haWxncmlkLWNvbHVtbg==', |
|
| 39 | sortDirection: null |
|
| 40 | }, |
|
| 41 | { |
|
| 42 | name: 'Address', |
|
| 43 | dataIndex: 'Address', |
|
| 44 | sortable: true, |
|
| 45 | className: 'additional-class', |
|
| 46 | id: 'QWRkcmVzc2dyaWQtY29sdW1u', |
|
| 47 | sortDirection: 'DESC' |
|
| 48 | } |
|
| 49 | ]; |
|
| 50 | ||
| 51 | const propColumns = [ |
|
| 52 | { |
|
| 53 | name: 'Phone Number', |
|
| 54 | dataIndex: 'Phone Number', |
|
| 55 | sortable: true, |
|
| 56 | className: 'additional-class' |
|
| 57 | }, |
|
| 58 | { |
|
| 59 | className: 'additional-class', |
|
| 60 | width: '45%', |
|
| 61 | dataIndex: ['person', 'name'], |
|
| 62 | hidden: false, |
|
| 63 | name: 'Name', |
|
| 64 | expandable: true, |
|
| 65 | sortable: true, |
|
| 66 | renderer: () => {} |
|
| 67 | }, |
|
| 68 | { |
|
| 69 | name: 'Email', |
|
| 70 | dataIndex: 'Email', |
|
| 71 | sortable: true, |
|
| 72 | className: 'additional-class', |
|
| 73 | defaultSortDirection: 'descend' |
|
| 74 | }, |
|
| 75 | { |
|
| 76 | name: 'Address', |
|
| 77 | dataIndex: 'Address', |
|
| 78 | sortable: true, |
|
| 79 | className: 'additional-class' |
|
| 80 | } |
|
| 81 | ]; |
|
| 82 | ||
| 83 | const result = [ |
|
| 84 | { |
|
| 85 | className: 'additional-class', |
|
| 86 | width: '40%', |
|
| 87 | dataIndex: ['person', 'name'], |
|
| 88 | hidden: true, |
|
| 89 | name: 'Name', |
|
| 90 | expandable: true, |
|
| 91 | sortable: true, |
|
| 92 | renderer: () => {} |
|
| 93 | }, |
|
| 94 | { |
|
| 95 | name: 'Phone Number', |
|
| 96 | dataIndex: 'Phone Number', |
|
| 97 | sortable: true, |
|
| 98 | className: 'additional-class' |
|
| 99 | }, |
|
| 100 | { |
|
| 101 | name: 'Email', |
|
| 102 | dataIndex: 'Email', |
|
| 103 | sortable: true, |
|
| 104 | className: 'additional-class', |
|
| 105 | defaultSortDirection: 'descend' |
|
| 106 | }, |
|
| 107 | { |
|
| 108 | name: 'Address', |
|
| 109 | dataIndex: 'Address', |
|
| 110 | sortable: true, |
|
| 111 | className: 'additional-class' |
|
| 112 | } |
|
| 113 | ]; |
|
| 114 | ||
| 115 | expect( |
|
| 116 | getColumnsFromStorage(storageCoumns, propColumns) |
|
| 117 | ).toEqual(result); |
|
| 118 | ||
| 119 | }); |
|
| 120 | ||
| 121 | it('Should map over a missing column', () => { |
|
| 122 | ||