Skip to content

Commit

Permalink
add failing test demoing ember-modifier/ember-modifier#851
Browse files Browse the repository at this point in the history
  • Loading branch information
amk221 committed Jun 20, 2024
1 parent b3c91a7 commit 1d43eb6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/integration/components/select-box/modifier-test.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'dummy/tests/helpers';
import { render, click } from '@ember/test-helpers';
import SelectBox from '@zestia/ember-select-box/components/select-box';
import { modifier } from 'ember-modifier';
import { tracked } from '@glimmer/tracking';

module('select-box', function (hooks) {
setupRenderingTest(hooks);

// Regression test for issue
// https://github.com/ember-modifier/ember-modifier/issues/851

const position = modifier(
(dropdown, [container]) => (dropdown.dataset.positioned = 'true'),
{ eager: false }
);

test('it does not blow up', async function (assert) {
assert.expect(0);

const state = new (class {
@tracked value;
})();

const handleChange = (value) => {
state.value = value;
};

await render(<template>
<SelectBox @value={{state.value}} @onChange={{handleChange}} as |sb|>
<sb.Trigger />
<sb.Options {{(if sb.isOpen (modifier position sb.element))}}>
<sb.Option @value="foo" />
</sb.Options>
</SelectBox>
</template>);

await click('.select-box__trigger'); // Open
await click('.select-box__option'); // Close
});
});

0 comments on commit 1d43eb6

Please sign in to comment.