From 61a62dde27a2a7262aaa37a765fbf35a51e2fd8c Mon Sep 17 00:00:00 2001 From: Casey Watts Date: Fri, 26 May 2017 18:22:58 -0400 Subject: [PATCH] Add working test of close closure action --- .../components/flash-message-test.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/integration/components/flash-message-test.js b/tests/integration/components/flash-message-test.js index fbd310bb..9d21cb2b 100644 --- a/tests/integration/components/flash-message-test.js +++ b/tests/integration/components/flash-message-test.js @@ -111,4 +111,29 @@ if (parseFloat(Ember.VERSION) > 2.0) { clock.restore(); }); + + test('a custom component can use the close closure action', function(assert) { + assert.expect(3); + + let destroyMessage = sinon.spy(); + this.set('flash', FlashMessage.create({ + message: 'flash message content', + sticky: true, + destroyOnClick: false, + destroyMessage + })); + + this.render(hbs` + {{#flash-message flash=flash as |component flash close|}} + {{flash.message}} + close + {{/flash-message}} + `); + + assert.notOk(destroyMessage.calledOnce, 'flash has not been destroyed yet'); + this.$(":contains(flash message content)").click(); + assert.notOk(destroyMessage.calledOnce, 'flash has not been destroyed yet'); + this.$(":contains(close)").click(); + assert.ok(destroyMessage.calledOnce, 'flash is destroyed after clicking close'); + }); }