From ed28ace5eac308ea53f78f3ac49a0a06332e9bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gre=CC=81gory=20Le=20Garec?= Date: Thu, 15 Jun 2017 17:43:34 +0200 Subject: [PATCH] tests: add test for service.resizeClient() error :umbrella: --- test/unit/intents.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/unit/intents.js b/test/unit/intents.js index dccc9a41..afeba243 100644 --- a/test/unit/intents.js +++ b/test/unit/intents.js @@ -438,6 +438,37 @@ describe('Intents', function () { windowMock.parent.postMessage .withArgs(messageMatch, expectedIntent.attributes.client).calledOnce.should.be.true() }) + + it('should not be called once the service has been terminated', async function () { + const windowMock = mockWindow() + + const clientHandshakeEventMessageMock = { + origin: expectedIntent.attributes.client, + data: { foo: 'bar' } + } + + const result = { + type: 'io.cozy.things' + } + + windowMock.parent.postMessage.callsFake(() => { + const messageEventListener = windowMock.addEventListener.secondCall.args[1] + messageEventListener(clientHandshakeEventMessageMock) + }) + + const service = await cozy.client.intents.createService(expectedIntent._id, windowMock) + + service.terminate(result) + + should.throws(() => { + service.resizeClient({ + element: { + clientHeight: 10, + clientWidth: 13 + } + }) + }, /Intent service has been terminated/) + }) }) describe('Terminate', function () {