forked from uber/baseweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data-table): add initial sort props (uber#3751)
* feat(data-table): add initial sort props * test(vrt): update visual snapshots for 7ee64bb [skip ci] (uber#3752) Co-authored-by: UberOpenSourceBot <[email protected]> * fix(data-table): lint Co-authored-by: UberOpenSourceBot <[email protected]> Co-authored-by: UberOpenSourceBot <[email protected]>
- Loading branch information
1 parent
7ddfa21
commit 4afdc10
Showing
8 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright (c) 2018-2020 Uber Technologies, Inc. | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
*/ | ||
/* eslint-env node */ | ||
/* eslint-disable flowtype/require-valid-file-annotation */ | ||
|
||
const {mount} = require('../../../e2e/helpers'); | ||
|
||
const { | ||
TABLE_ROOT, | ||
getCellContentsAtColumnIndex, | ||
matchArrayElements, | ||
} = require('./utilities.js'); | ||
|
||
const COLUMN_COUNT = 1; | ||
|
||
describe('data table initial filters', () => { | ||
it('mounts with initial sort applied', async () => { | ||
await mount(page, 'data-table-initial-sort'); | ||
await page.waitFor(TABLE_ROOT); | ||
const data = await getCellContentsAtColumnIndex(page, COLUMN_COUNT, 0); | ||
expect(matchArrayElements(data, ['d', 'c', 'b', 'a'])).toBe(true); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
src/data-table/__tests__/data-table-initial-sort.scenario.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright (c) 2018-2020 Uber Technologies, Inc. | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
*/ | ||
// @flow | ||
|
||
import * as React from 'react'; | ||
|
||
import { | ||
Unstable_StatefulDataTable, | ||
CategoricalColumn, | ||
SORT_DIRECTIONS, | ||
} from '../index.js'; | ||
|
||
export default function Scenario() { | ||
const columns = [ | ||
CategoricalColumn({ | ||
title: 'column', | ||
mapDataToValue: (data: string) => data, | ||
}), | ||
]; | ||
|
||
const rows = [ | ||
{id: 1, data: 'a'}, | ||
{id: 2, data: 'b'}, | ||
{id: 3, data: 'c'}, | ||
{id: 4, data: 'd'}, | ||
]; | ||
|
||
return ( | ||
<React.Fragment> | ||
<div style={{height: '400px', width: '800px'}}> | ||
<Unstable_StatefulDataTable | ||
columns={columns} | ||
rows={rows} | ||
initialSortIndex={0} | ||
initialSortDirection={SORT_DIRECTIONS.ASC} | ||
/> | ||
</div> | ||
</React.Fragment> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.