Skip to content

Commit

Permalink
tests: add test for service.resizeClient() error ☔
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorylegarec committed Jun 15, 2017
1 parent 41de86b commit ed28ace
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/unit/intents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit ed28ace

Please sign in to comment.