2023-03-15 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2019-10-14 18:23:29 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
|
|
import { click, render } from '@ember/test-helpers';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
module('Integration | Component | raft-join', function (hooks) {
|
2019-10-14 18:23:29 +00:00
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it renders', async function (assert) {
|
2019-10-14 18:23:29 +00:00
|
|
|
await render(hbs`<RaftJoin />`);
|
|
|
|
assert.dom('[data-test-join-choice]').exists();
|
|
|
|
});
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it shows the join form when clicking next', async function (assert) {
|
2019-10-14 18:23:29 +00:00
|
|
|
await render(hbs`<RaftJoin />`);
|
|
|
|
await click('[data-test-next]');
|
|
|
|
assert.dom('[data-test-join-header]').exists();
|
|
|
|
});
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it returns to the first screen when clicking back', async function (assert) {
|
2019-10-14 18:23:29 +00:00
|
|
|
await render(hbs`<RaftJoin />`);
|
|
|
|
await click('[data-test-next]');
|
|
|
|
assert.dom('[data-test-join-header]').exists();
|
|
|
|
await click('[data-test-cancel-button]');
|
|
|
|
assert.dom('[data-test-join-choice]').exists();
|
|
|
|
});
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it calls onDismiss when a user chooses to init', async function (assert) {
|
2022-11-09 23:15:31 +00:00
|
|
|
const spy = sinon.spy();
|
2019-10-14 18:23:29 +00:00
|
|
|
this.set('onDismiss', spy);
|
2022-10-18 15:46:02 +00:00
|
|
|
await render(hbs`<RaftJoin @onDismiss={{this.onDismiss}} />`);
|
2019-10-14 18:23:29 +00:00
|
|
|
|
|
|
|
await click('[data-test-join-init]');
|
|
|
|
await click('[data-test-next]');
|
|
|
|
assert.ok(spy.calledOnce, 'it calls the passed onDismiss');
|
|
|
|
});
|
|
|
|
});
|