github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/tests/integration/components/das/dismissed-test.js (about) 1 import { module, test } from 'qunit'; 2 import { setupRenderingTest } from 'ember-qunit'; 3 import { click, render } from '@ember/test-helpers'; 4 import { hbs } from 'ember-cli-htmlbars'; 5 import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit'; 6 import sinon from 'sinon'; 7 8 module('Integration | Component | das/dismissed', function(hooks) { 9 setupRenderingTest(hooks); 10 11 hooks.beforeEach(function() { 12 window.localStorage.clear(); 13 }); 14 15 test('it renders the dismissal interstitial with a button to proceed and an option to never show again and proceeds manually', async function(assert) { 16 const proceedSpy = sinon.spy(); 17 this.set('proceedSpy', proceedSpy); 18 19 await render(hbs`<Das::Dismissed @proceed={{proceedSpy}} />`); 20 21 await componentA11yAudit(this.element, assert); 22 23 await click('input[type=checkbox]'); 24 await click('[data-test-understood]'); 25 26 assert.ok(proceedSpy.calledWith({ manuallyDismissed: true })); 27 assert.equal(window.localStorage.getItem('nomadRecommendationDismssalUnderstood'), 'true'); 28 }); 29 30 test('it renders the dismissal interstitial with no button when the option to never show again has been chosen and proceeds automatically', async function(assert) { 31 window.localStorage.setItem('nomadRecommendationDismssalUnderstood', true); 32 33 const proceedSpy = sinon.spy(); 34 this.set('proceedSpy', proceedSpy); 35 36 await render(hbs`<Das::Dismissed @proceed={{proceedSpy}} />`); 37 38 assert.dom('[data-test-understood]').doesNotExist(); 39 40 await componentA11yAudit(this.element, assert); 41 42 assert.ok(proceedSpy.calledWith({ manuallyDismissed: false })); 43 }); 44 });