diff --git a/test-app/tests/integration/modifiers/sortable-item-test.js b/test-app/tests/integration/modifiers/sortable-item-test.js new file mode 100644 index 00000000..0d54f003 --- /dev/null +++ b/test-app/tests/integration/modifiers/sortable-item-test.js @@ -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` +
    + {{#each this.items as |item|}} +
  1. {{item}}
  2. + {{/each}} +
+ `); + + 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+$/, ''); + } +});