Files
threshold-ui/addons/core/tests/integration/components/pending-confirmations-test.js
T
Devon Anderson 9e7852f18d chore: 🤖 Upgrade addons/core to Ember 4.12.2 (#1965)
* chore: 🤖 Upgrade `addons/core` to Ember 4.12.2

Upgrade `addons/core` to Ember 4.12.2

✅ Closes: ICU-11341

* refactor: 💡 testing updating plugin-proposal-decorators version

Update `@babel/plugin-proposal-decorators` to latest version.

* refactor: 💡 testing legacy plugin-proposa-decorators version

Testin `legacy` version for `plugin-proposal-decorators` plugin

* refactor: 💡 testing plugin-proposal-decorators

Testing `@babel/plugin-proposal-decorators`

* refactor: 💡 Revert @babel/exlint-parser to previous version

Revert `@babel/eslint-parser` to use version 2018 EcmaScript version
until further research is done on latest versions

* Update package.json

put @babel/core back into `devDependencies`

* refactor: 💡 testing linging changes

Pushed ember-tempalate-lint, prettier, and ember template lint plugin
for prettier to latest versions to test why CI builds are not passing.

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-11341
2023-10-27 11:10:30 -04:00

64 lines
2.4 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, findAll, click } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | pending-confirmations', function (hooks) {
setupRenderingTest(hooks);
test('it renders pending confirmations', async function (assert) {
assert.expect(2);
const service = this.owner.lookup('service:confirm');
service.enabled = true;
await render(hbs`<PendingConfirmations as |confirmation|>
<div class='pending'>{{confirmation.text}}</div>
</PendingConfirmations>`);
assert.strictEqual(
findAll('.pending').length,
0,
'No pending confirmations',
);
service.confirm('Text', { type: 'pending' });
await render(hbs`<PendingConfirmations as |confirmation|>
<div class='pending'>{{confirmation.text}}</div></PendingConfirmations>`);
assert.strictEqual(
findAll('.pending').length,
1,
'One pending confirmations',
);
});
test('it exposes a confirm action that confirms the confirmation', async function (assert) {
assert.expect(3);
const service = this.owner.lookup('service:confirm');
service.enabled = true;
const confirmation = service.confirm();
confirmation.then(() => assert.ok(true, 'confirmation.then was called'));
await render(hbs`<PendingConfirmations as |confirmations confirm|>
<button type='button' {{on 'click' confirm}}>Confirm</button>
</PendingConfirmations>`);
assert.notOk(confirmation.done, 'Confirmation is not done');
await click('button');
assert.ok(confirmation.done, 'Confirmation is done');
});
test('it exposes a dismiss action that dismisses the confirmation', async function (assert) {
assert.expect(3);
const service = this.owner.lookup('service:confirm');
service.enabled = true;
const confirmation = service.confirm();
confirmation.catch(() => assert.ok(true, 'confirmation.catch was called'));
await render(hbs`<PendingConfirmations as |confirmations confirm dismiss|>
<button type='button' {{on 'click' dismiss}}>Dismiss</button>
</PendingConfirmations>`);
assert.notOk(confirmation.done, 'Confirmation is not done');
await click('button');
assert.ok(confirmation.done, 'Confirmation is done');
});
});