2019-08-31 20:51:14 -07:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
|
|
import { render, findAll, triggerEvent } from '@ember/test-helpers';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
|
2020-08-26 15:44:50 -07:00
|
|
|
module('Integration | Component | radio-button-composer', function(hooks): void {
|
2019-08-31 20:51:14 -07:00
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
|
|
|
const disabledClass = 'paralyzed-pikachu';
|
|
|
|
|
2020-08-26 15:44:50 -07:00
|
|
|
test('decorated properties behave as expected', async function(assert): Promise<void> {
|
2019-08-31 20:51:14 -07:00
|
|
|
this.setProperties({
|
|
|
|
disabledClass,
|
|
|
|
value: 'electrify',
|
|
|
|
mouseEnter() {
|
|
|
|
assert.ok(true, 'Function got called on mouseEnter');
|
|
|
|
}
|
|
|
|
});
|
2020-10-11 11:40:32 -07:00
|
|
|
await render(hbs`<RadioButtonComposer
|
|
|
|
@disabledClass={{this.disabledClass}}
|
|
|
|
@name="testA"
|
|
|
|
@groupValue="groupA"
|
|
|
|
@value={{this.value}}
|
|
|
|
@onMouseEnter={{this.mouseEnter}}
|
|
|
|
>
|
|
|
|
{{value}}
|
|
|
|
</RadioButtonComposer>`);
|
2019-08-31 20:51:14 -07:00
|
|
|
|
|
|
|
// Ensures the function assert was called.
|
2020-10-11 11:40:32 -07:00
|
|
|
assert.expect(5);
|
2020-08-26 15:44:50 -07:00
|
|
|
assert.equal(this.element.textContent?.trim(), 'electrify', 'renders expected value');
|
2019-08-31 20:51:14 -07:00
|
|
|
assert.equal(findAll(`.${disabledClass}`).length, 0, 'Does not disable when not supposed to');
|
|
|
|
|
2020-10-11 11:40:32 -07:00
|
|
|
await triggerEvent('span', 'mouseenter');
|
2019-08-31 20:51:14 -07:00
|
|
|
|
2020-10-11 11:40:32 -07:00
|
|
|
await render(hbs`<RadioButtonComposer
|
|
|
|
@disabledClass={{this.disabledClass}}
|
|
|
|
@name="testB"
|
|
|
|
@groupValue="groupB"
|
|
|
|
@value={{this.value}}
|
|
|
|
@onMouseEnter={{this.mouseEnter}}
|
|
|
|
@disabled={{true}} />`);
|
2019-08-31 20:51:14 -07:00
|
|
|
|
|
|
|
assert.equal(findAll(`.${disabledClass}`).length, 1, 'Renders the disabled class');
|
2020-10-11 11:40:32 -07:00
|
|
|
await triggerEvent('span', 'mouseenter');
|
2019-08-31 20:51:14 -07:00
|
|
|
});
|
|
|
|
});
|