-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'data-process' into support-drill-down
# Conflicts: # packages/s2-core/package.json # packages/s2-core/src/cell/data-derived-cell.ts # packages/s2-core/src/common/store/index.ts # packages/s2-core/src/sheet-type/index.ts
- Loading branch information
Showing
8 changed files
with
213 additions
and
41 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const { prompt } = require('inquirer'); | ||
const { execSync } = require('child_process'); | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
const ora = require('ora'); | ||
|
||
async function main() { | ||
const spinner = ora('读取测试文件中...').start(); | ||
const paths = glob.sync(`!(node_modules)/**/*-spec.ts?(x)`); | ||
const defaultFilename = path.relative( | ||
process.cwd(), | ||
'tests/unit/spread-sheet-spec.tsx', | ||
); | ||
spinner.stop(); | ||
|
||
const selectedPath = await prompt([ | ||
{ | ||
type: 'list', | ||
message: '请选择测试文件', | ||
name: 'path', | ||
choices: paths, | ||
default: () => defaultFilename, | ||
}, | ||
]); | ||
|
||
const jestSpinner = ora('测试运行中...').start(); | ||
try { | ||
execSync(`DEBUG_MODE=1 jest ${selectedPath.path}`); | ||
jestSpinner.succeed('测试运行完成.'); | ||
} catch (error) { | ||
jestSpinner.fail(); | ||
} | ||
} | ||
|
||
main(); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { RowCell } from '@/cell/row-cell'; | ||
import { SelectedStateName } from '@/common/constant/interatcion'; | ||
import { SpreadSheet } from '@/sheet-type'; | ||
import { State } from '@/state/state'; | ||
|
||
jest.mock('@/sheet-type'); | ||
jest.mock('@/cell/row-cell'); | ||
const MockSpreadSheet = (SpreadSheet as any) as jest.Mock<SpreadSheet>; | ||
const MockRowCell = (RowCell as any) as jest.Mock<RowCell>; | ||
describe('State Test', () => { | ||
let state: State; | ||
let mockInstance; | ||
let mockRowCellInstance; | ||
|
||
beforeEach(() => { | ||
MockSpreadSheet.mockClear(); | ||
MockRowCell.mockClear(); | ||
|
||
mockInstance = new MockSpreadSheet(); | ||
mockRowCellInstance = new MockRowCell(); | ||
|
||
state = new State(mockInstance); | ||
}); | ||
test('should set select status correctly', () => { | ||
expect(state.getCurrentState()).toEqual({ | ||
stateName: '', | ||
cells: [], | ||
}); | ||
|
||
state.setState(mockRowCellInstance, SelectedStateName.ROW_SELECTED); | ||
|
||
expect(state.getCurrentState()).toEqual({ | ||
stateName: SelectedStateName.ROW_SELECTED, | ||
cells: [mockRowCellInstance], | ||
}); | ||
}); | ||
|
||
test("should push row cell in current state when state doestn't include it", () => { | ||
state.setState(mockRowCellInstance, SelectedStateName.ROW_SELECTED); | ||
|
||
expect(state.getCurrentState()).toEqual({ | ||
stateName: SelectedStateName.ROW_SELECTED, | ||
cells: [mockRowCellInstance], | ||
}); | ||
|
||
const other = new MockRowCell(); | ||
state.setState(other, SelectedStateName.ROW_SELECTED); | ||
|
||
expect(state.getCurrentState()).toEqual({ | ||
stateName: SelectedStateName.ROW_SELECTED, | ||
cells: [mockRowCellInstance, other], | ||
}); | ||
}); | ||
|
||
test('should do nothing when state includes it', () => { | ||
state.setState(mockRowCellInstance, SelectedStateName.ROW_SELECTED); | ||
|
||
expect(state.getCurrentState()).toEqual({ | ||
stateName: SelectedStateName.ROW_SELECTED, | ||
cells: [mockRowCellInstance], | ||
}); | ||
|
||
state.setState(mockRowCellInstance, SelectedStateName.ROW_SELECTED); | ||
|
||
expect(state.getCurrentState()).toEqual({ | ||
stateName: SelectedStateName.ROW_SELECTED, | ||
cells: [mockRowCellInstance], | ||
}); | ||
}); | ||
|
||
test('should clear existed state when call clearState function', () => { | ||
state.setState(mockRowCellInstance, SelectedStateName.ROW_SELECTED); | ||
|
||
expect(state.getCurrentState()).toEqual({ | ||
stateName: SelectedStateName.ROW_SELECTED, | ||
cells: [mockRowCellInstance], | ||
}); | ||
|
||
state.clearState(); | ||
|
||
expect(state.getCurrentState()).toEqual({ | ||
stateName: '', | ||
cells: [], | ||
}); | ||
}); | ||
}); |