Skip to content

Commit

Permalink
Add test for transitionDuration when only one item is present which…
Browse files Browse the repository at this point in the history
… will be moved
  • Loading branch information
mkszepp committed Aug 3, 2024
1 parent a076250 commit 5d58268
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test-app/tests/integration/modifiers/sortable-item-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { find, render } from '@ember/test-helpers';
import { set } from '@ember/object';
import { drag } from 'ember-sortable/test-support';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Modifier | sortable-item', function (hooks) {
setupRenderingTest(hooks);

test('Drag works with one item', async function (assert) {
this.items = ['Uno'];

this.update = (items) => {
set(this, 'items', items);
};

await render(hbs`
<ol id="test-list" {{sortable-group onChange=this.update}}>
{{#each this.items as |item|}}
<li data-test-item {{sortable-item model=item}}>{{item}}</li>
{{/each}}
</ol>
`);

await drag('mouse', '[data-test-item]', () => {
return { dy: 10 };
});

assert.equal(contents('#test-list'), 'Uno');
});

function contents(selector) {
return find(selector).textContent.replace(//g, '').replace(/\s+/g, ' ').replace(/^\s+/, '').replace(/\s+$/, '');
}
});

0 comments on commit 5d58268

Please sign in to comment.