Skip to content

Commit

Permalink
updated unit/integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
didoo committed Apr 15, 2024
1 parent 113a77d commit ea00511
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions showcase/tests/integration/modifiers/hds-anchored-position-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,19 @@ module(
assert.deepEqual(floatingUIOptions.middleware[3].name, 'test');
assert.deepEqual(floatingUIOptions.middleware[3].options, { abc: 1234 });
});
test('returns the `arrowElement` provided as an option', async function (assert) {
test('returns the `arrow` provided as an option', async function (assert) {
const floatingUIOptions = getFloatingUIOptions({
// notice: this in reality should be a DOM element, but we found a string works as well for this type of test
arrowElement: 'test1234',
arrowPadding: 1234,
arrowOptions: {
element: 'test1234',
selector: '#test1234',
padding: 1234,
},
});
assert.deepEqual(floatingUIOptions.middleware[1].name, 'arrow');
assert.deepEqual(floatingUIOptions.middleware[1].options, {
element: 'test1234',
selector: '#test1234',
padding: 1234,
});
});
Expand Down Expand Up @@ -200,7 +204,7 @@ module('Integration | Modifier | hds-anchored-position', function (hooks) {
}
});

test('render "anchor/floating" elements with default `options`', async function (assert) {
test('render "anchor/floating/arrow" elements with default `options`', async function (assert) {
await render(hbs`
<div id="wrapper">
<div id="anchor">anchor</div>
Expand All @@ -210,7 +214,7 @@ module('Integration | Modifier | hds-anchored-position', function (hooks) {
this.anchorElement = document.getElementById('anchor');
this.floatingElement = document.getElementById('floating');
this.arrowElement = document.getElementById('arrow');
this.floatingOptions = { arrow: this.arrowElement };
this.floatingOptions = { arrowOptions: { element: this.arrowElement } };
// apply the modifier to the testing elements (after the rendering)
await anchoredElementModifier(
this.floatingElement, // element the modifier is attached to
Expand All @@ -231,7 +235,7 @@ module('Integration | Modifier | hds-anchored-position', function (hooks) {
);
});

test('render "anchor/floating" elements with custom options', async function (assert) {
test('render "anchor/floating/arrow" elements with custom options', async function (assert) {
await render(hbs`
<div id="wrapper">
<div id="anchor">anchor</div>
Expand All @@ -245,7 +249,7 @@ module('Integration | Modifier | hds-anchored-position', function (hooks) {
placement: 'bottom-start',
strategy: 'fixed',
offsetOptions: 20,
arrow: this.arrowElement,
arrowOptions: { element: this.arrowElement },
};
// apply the modifier to the elements (after the rendering)
await anchoredElementModifier(
Expand All @@ -271,7 +275,7 @@ module('Integration | Modifier | hds-anchored-position', function (hooks) {
await render(hbs`
<div id="wrapper">
<div id="anchor">anchor</div>
<div id="floating" {{hds-anchored-position '#anchor' placement='bottom-start' strategy='fixed' offsetOptions=20 arrow='#arrow' }}><div id="arrow"></div>floating</div>
<div id="floating" {{hds-anchored-position '#anchor' placement='bottom-start' strategy='fixed' offsetOptions=20 arrowOptions=(hash selector='#arrow') }}><div id="arrow"></div>floating</div>
</div>
`);
this.anchorElement = document.getElementById('anchor');
Expand Down

0 comments on commit ea00511

Please sign in to comment.