From e2ed55e9ddcd5f2bb3562f52b7be9b787588d75f Mon Sep 17 00:00:00 2001 From: Ashley Blurton Date: Thu, 21 Apr 2016 16:06:20 +0100 Subject: [PATCH] Add test case for new event serialization --- src/client/__tests__/client_api.js | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/client/__tests__/client_api.js b/src/client/__tests__/client_api.js index 55a5aa3d3289..700dd81535a0 100644 --- a/src/client/__tests__/client_api.js +++ b/src/client/__tests__/client_api.js @@ -162,6 +162,38 @@ describe('client.ClientApi', () => { count: 1, }]); }); + + it('should replace any Synthetic Event with it\'s name when not the first argument', () => { + const api = getClientApi(); + api._syncedStore.getData = () => ({ actions: [] }); + api._syncedStore.setData = sinon.stub(); + + const event = { + preventDefault() {}, + }; + const data = { + type: 'delete', + }; + + const cb = api.action('hello'); + cb(data, event); + + const args = api._syncedStore.setData.args[0]; + const actions = clearActionId(args[0].actions); + + expect(actions).to.be.deep.equal([{ + data: { + name: 'hello', + args: [ + { + type: 'delete', + }, + '[SyntheticEvent]', + ], + }, + count: 1, + }]); + }); }); describe('linkTo', () => {