Skip to content

Commit

Permalink
Cleanup PR
Browse files Browse the repository at this point in the history
  • Loading branch information
mnoble01 committed Nov 13, 2019
1 parent 95a83e2 commit ce1b192
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 83 deletions.
72 changes: 36 additions & 36 deletions tests/integration/components/draggable-object-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module('Integration | Component | draggable object', function(hooks){

test('draggable object renders', async function(assert) {
assert.expect(2);

await render(hbs`{{draggable-object}}`);

assert.equal(this.element.innerText.trim(), '');

await render(hbs`
{{#draggable-object}}
template block text
Expand All @@ -22,95 +22,95 @@ module('Integration | Component | draggable object', function(hooks){

assert.equal(this.element.innerText.trim(), 'template block text');
});

test('Draggable Object is draggable', async function(assert) {
assert.expect(3);

let event = new MockEvent();

this.set('dragMoveAction', (event) => assert.ok(event));

await render(hbs`
{{#draggable-object content=myObject class='draggable-object' dragMoveAction=(action dragMoveAction)}}
Hi
<a class="js-dragHandle dragHandle"></a>
{{/draggable-object}}
`);

let componentSelector = '.draggable-object';

await triggerEvent(componentSelector, 'dragstart', event);

assert.equal(find(componentSelector).classList.contains('is-dragging-object'), true);

await triggerEvent(componentSelector, 'drag', event);

await triggerEvent(componentSelector, 'dragend', event);

assert.equal(find(componentSelector).classList.contains('is-dragging-object'), false);

});

test('Draggable Object is only draggable from handle', async function(assert) {
assert.expect(6);

let event = new MockEvent();

await render(hbs`
{{#draggable-object content=myObject class='draggable-object' dragHandle='.js-dragHandle'}}
Main Component
<a class="js-dragHandle dragHandle"></a>
{{/draggable-object}}
`);

let componentSelector = '.draggable-object';

//does not drag from main component
await triggerEvent(componentSelector, 'dragstart', event);
assert.equal(find(componentSelector).classList.contains('is-dragging-object'), false);

//end drag
await triggerEvent(componentSelector, 'dragend', event);

assert.equal(find(componentSelector).classList.contains('is-dragging-object'), false);

//make sure parent element does not have draggable attribute until handle is clicked
assert.equal(find(componentSelector).getAttribute('draggable'), "false");

await triggerEvent('.js-dragHandle', 'mouseover');

assert.equal(find(componentSelector).getAttribute('draggable'), "true");

//Drag should start now that the handle is down
await triggerEvent(componentSelector, 'dragstart', event);

assert.equal(find(componentSelector).classList.contains('is-dragging-object'), true);

//Drag has ended draggable attribute should be removed
await triggerEvent(componentSelector, 'dragend', event);

assert.equal(find(componentSelector).getAttribute('draggable'), "false");

});

test('Draggable hooks are overridable', async function(assert) {
assert.expect(2);

let event = new MockEvent();

this.set('dragStartAction', (event) => assert.ok(event));

this.set('dragEndAction', (event) => assert.ok(event));

await render(hbs`
{{#draggable-object class='draggable-object' dragStartHook=(action dragStartAction) dragEndHook=(action dragEndAction)}}
{{/draggable-object}}
`);

let componentSelector = '.draggable-object';

await triggerEvent(componentSelector, 'dragstart', event);

await triggerEvent(componentSelector, 'dragend', event);
});
});
1 change: 1 addition & 0 deletions tests/integration/components/helpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ module('Integration | Helpers', function(hooks) {
});

});

8 changes: 4 additions & 4 deletions tests/integration/components/object-bin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ module('Integration | Component | object bin', function(hooks) {
let obj = EmberObject.create({ title2: "Hello" }),
all = A();
all.addObject(obj);

this.set('all', all);

await render(hbs`{{#object-bin title2='notit' model=all as |obj|}}<span class='title2'>{{obj.title2}}</span>{{/object-bin}}`);

assert.equal(findAll('.title2').length, 1);
assert.equal(find('.title2').textContent.trim(), "Hello");
});
});
});
Loading

0 comments on commit ce1b192

Please sign in to comment.