Files
nomad/ui/tests/integration/components/das/dismissed-test.js
Jai Bhagat 2032813bb6 ui: apply new qunit linting rules to tests
Async tests should use  in integrations tests.
Acceptance tests are using Mirage and can't use
since we can't know the number of assertions.
2022-01-20 10:01:35 -05:00

52 lines
1.7 KiB
JavaScript

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { click, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit';
import sinon from 'sinon';
module('Integration | Component | das/dismissed', function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
window.localStorage.clear();
});
test('it renders the dismissal interstitial with a button to proceed and an option to never show again and proceeds manually', async function (assert) {
assert.expect(3);
const proceedSpy = sinon.spy();
this.set('proceedSpy', proceedSpy);
await render(hbs`<Das::Dismissed @proceed={{proceedSpy}} />`);
await componentA11yAudit(this.element, assert);
await click('input[type=checkbox]');
await click('[data-test-understood]');
assert.ok(proceedSpy.calledWith({ manuallyDismissed: true }));
assert.equal(
window.localStorage.getItem('nomadRecommendationDismssalUnderstood'),
'true'
);
});
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) {
assert.expect(3);
window.localStorage.setItem('nomadRecommendationDismssalUnderstood', true);
const proceedSpy = sinon.spy();
this.set('proceedSpy', proceedSpy);
await render(hbs`<Das::Dismissed @proceed={{proceedSpy}} />`);
assert.dom('[data-test-understood]').doesNotExist();
await componentA11yAudit(this.element, assert);
assert.ok(proceedSpy.calledWith({ manuallyDismissed: false }));
});
});