github.com/outbrain/consul@v1.4.5/ui-v2/tests/integration/mixins/with-resizing-test.js (about) 1 import { module } from 'qunit'; 2 import test from 'ember-sinon-qunit/test-support/test'; 3 import { setupTest } from 'ember-qunit'; 4 import EmberObject from '@ember/object'; 5 import Mixin from 'consul-ui/mixins/with-resizing'; 6 module('Integration | Mixin | with-resizing', function(hooks) { 7 setupTest(hooks); 8 test('window.addEventListener, resize and window.removeEventListener are called once each through the entire lifecycle', function(assert) { 9 const win = { 10 innerWidth: 0, 11 innerHeight: 0, 12 addEventListener: this.stub(), 13 removeEventListener: this.stub(), 14 }; 15 const subject = EmberObject.extend(Mixin, { 16 win: win, 17 }).create(); 18 const resize = this.stub(subject, 'resize'); 19 subject.didInsertElement(); 20 subject.willDestroyElement(); 21 assert.ok(win.addEventListener.calledOnce); 22 assert.ok(resize.calledOnce); 23 assert.ok(resize.calledWith({ detail: { width: 0, height: 0 } })); 24 assert.ok(win.removeEventListener.calledOnce); 25 }); 26 });