-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4ae432
commit 518b073
Showing
47 changed files
with
624 additions
and
214 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
packages/s2-core/__tests__/spreadsheet/interaction-cell-selected-event-spec.ts
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,57 @@ | ||
import { S2Event } from '@/common/constant'; | ||
import { type S2Options } from '@/common/interface'; | ||
import { SpreadSheet } from '@/sheet-type'; | ||
import { createPivotSheet } from 'tests/util/helpers'; | ||
import { CellType } from '../../src'; | ||
|
||
const s2Options: S2Options = { | ||
width: 600, | ||
height: 400, | ||
}; | ||
|
||
describe('Interaction Cell Selected Event Tests', () => { | ||
let s2: SpreadSheet; | ||
|
||
beforeEach(async () => { | ||
s2 = createPivotSheet(s2Options); | ||
await s2.render(); | ||
}); | ||
|
||
afterEach(() => { | ||
s2.destroy(); | ||
}); | ||
|
||
test.each` | ||
cellType | event | ||
${CellType.CORNER_CELL} | ${S2Event.CORNER_CELL_SELECTED} | ||
${CellType.ROW_CELL} | ${S2Event.ROW_CELL_SELECTED} | ||
${CellType.COL_CELL} | ${S2Event.COL_CELL_SELECTED} | ||
${CellType.DATA_CELL} | ${S2Event.DATA_CELL_SELECTED} | ||
`( | ||
'should get $cellType detail when $event is triggered', | ||
({ cellType, event }) => { | ||
const fn = jest.fn(); | ||
const onSelected = jest.fn(); | ||
|
||
s2.on(event, fn); | ||
s2.on(S2Event.GLOBAL_SELECTED, onSelected); | ||
|
||
s2.interaction.emitSelectEvent({ | ||
targetCell: { | ||
cellType, | ||
}, | ||
}); | ||
|
||
expect(onSelected).toHaveBeenCalledWith(expect.anything(), { | ||
targetCell: { | ||
cellType, | ||
}, | ||
}); | ||
expect(fn).toHaveBeenCalledWith(expect.anything(), { | ||
targetCell: { | ||
cellType, | ||
}, | ||
}); | ||
}, | ||
); | ||
}); |
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
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
Oops, something went wrong.