-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add failing test demoing ember-modifier/ember-modifier#851
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); | ||
}); |