Mailspring/spec/fixtures/table-data.es6
Juan Tejada eb79ce9d44 specs(table): Add specs for table components
Summary:
- Add some docs to Table components
- Updates Table components to use a TableDataSource instead of accessing arrays, cleans up code a bit
- Add enzyme lib to have a cleaner and simpler api to write tests for React Components
- Updates decorators to extend from the BaseComponent instead of vanilla Component, this way instance methods are still available on composed components

Test Plan: - Unit tests

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2941
2016-05-11 14:36:59 -07:00

31 lines
843 B
JavaScript

import {Table} from 'nylas-component-kit'
export const testData = {
columns: ['col1', 'col2', 'col3'],
rows: [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
],
}
class TestSource extends Table.TableDataSource {
setRows(rows) {
const data = {
rows: [...rows],
columns: this.columns(),
}
return new TestSource(data)
}
}
export const testDataSource = new TestSource(testData)
export const selection = {colIdx: 0, rowIdx: 0, key: null}
export const cellProps = {tableDataSource: testDataSource, selection, colIdx: 0, rowIdx: 0, onSetSelection: () => {}, onCellEdited: () => {}}
export const rowProps = {tableDataSource: testDataSource, selection, rowIdx: 0}
export const tableProps = {tableDataSource: testDataSource, selection, onSetSelection: () => {}, onShiftSelection: () => {}, onCellEdited: () => {}}