mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-05 13:59:56 +08:00
fix(actions-core): Added scrollTo with no params error test.
This commit is contained in:
parent
32c0b7c96f
commit
140218075f
@ -64,6 +64,18 @@ beforeEach(() => {
|
||||
mockElemScrollIntoView.mockReset();
|
||||
});
|
||||
|
||||
const RealDate = Date;
|
||||
const mockDate = jest.fn(() => ({ date: 0 }));
|
||||
mockDate.now = jest.fn(() => 0);
|
||||
|
||||
beforeAll(() => {
|
||||
global.Date = mockDate;
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
global.Date = RealDate;
|
||||
});
|
||||
|
||||
test('ScrollTo with no params', async () => {
|
||||
const rootBlock = {
|
||||
id: 'block:root:root:0',
|
||||
@ -95,8 +107,34 @@ test('ScrollTo with no params', async () => {
|
||||
rootBlock,
|
||||
});
|
||||
const button = context._internal.RootBlocks.map['block:root:button:0'];
|
||||
button.triggerEvent({ name: 'onClick' });
|
||||
expect(mockWindowScrollTo.mock.calls).toEqual([]);
|
||||
const res = await button.triggerEvent({ name: 'onClick' });
|
||||
expect(res).toEqual({
|
||||
blockId: 'button',
|
||||
bounced: false,
|
||||
endTimestamp: { date: 0 },
|
||||
error: {
|
||||
action: {
|
||||
id: 'a',
|
||||
type: 'ScrollTo',
|
||||
},
|
||||
error: {
|
||||
error: new Error('Invalid ScrollTo, check action params. Received "undefined".'),
|
||||
index: 0,
|
||||
type: 'ScrollTo',
|
||||
},
|
||||
},
|
||||
event: undefined,
|
||||
eventName: 'onClick',
|
||||
responses: {
|
||||
a: {
|
||||
error: new Error('Invalid ScrollTo, check action params. Received "undefined".'),
|
||||
index: 0,
|
||||
type: 'ScrollTo',
|
||||
},
|
||||
},
|
||||
startTimestamp: { date: 0 },
|
||||
success: false,
|
||||
});
|
||||
});
|
||||
|
||||
test('ScrollTo with no blockId', async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user