Skip to content

Commit

Permalink
Modernize test templates
Browse files Browse the repository at this point in the history
  • Loading branch information
dgavey committed Mar 31, 2021
1 parent bac3bf8 commit 89c24a3
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 307 deletions.
22 changes: 11 additions & 11 deletions tests/integration/components/draggable-object-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ module('Integration | Component | draggable object', function(hooks){
test('draggable object renders', async function(assert) {
assert.expect(2);

await render(hbs`{{draggable-object}}`);
await render(hbs`<DraggableObject />`);

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

await render(hbs`
{{#draggable-object}}
<DraggableObject>
template block text
{{/draggable-object}}
</DraggableObject>
`);

assert.equal(this.element.innerText.trim(), 'template block text');
Expand All @@ -31,10 +31,10 @@ module('Integration | Component | draggable object', function(hooks){
this.set('dragMoveAction', (event) => assert.ok(event));

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

let componentSelector = '.draggable-object';
Expand All @@ -57,10 +57,10 @@ module('Integration | Component | draggable object', function(hooks){
let event = new MockEvent();

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

let componentSelector = '.draggable-object';
Expand Down Expand Up @@ -103,8 +103,8 @@ module('Integration | Component | draggable object', function(hooks){
this.set('dragEndAction', (event) => assert.ok(event));

await render(hbs`
{{#draggable-object class='draggable-object' dragStartHook=(action dragStartAction) dragEndHook=(action dragEndAction)}}
{{/draggable-object}}
<DraggableObject class='draggable-object' @dragStartHook={{fn this.dragStartAction}} @dragEndHook={{fn this.dragEndAction}}>
</DraggableObject>
`);

let componentSelector = '.draggable-object';
Expand Down
11 changes: 6 additions & 5 deletions tests/integration/components/helpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ module('Integration | Helpers', function(hooks) {

const collection = ['hiphop', 'jazz', 'funk'];
const template = hbs`
{{#each collection as |genre index|}}
{{#draggable-object classNames=genre coordinator=coordinator content=genre}}
<div class="item">{{genre}}</div>
{{/draggable-object}}
{{#each this.collection as |genre index|}}
<DraggableObject class={{genre}} @coordinator={{this.coordinator}} @content={{genre}}>
<div class="item">{{this.genre}}</div>
</DraggableObject>
{{draggable-object-target classNames=genre class='drop-target' action=(action dropAction) destination=index coordinator=coordinator}}
<DraggableObjectTarget class="drop-target {{genre}}" @action={{fn this.dropAction}} @destination={{index}} @coordinator={{this.coordinator}} />
{{/each}}
`;

Expand Down
23 changes: 0 additions & 23 deletions tests/integration/components/object-bin-test.js

This file was deleted.

60 changes: 30 additions & 30 deletions tests/integration/components/sortable-objects-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ module('Integration | Component | sortable objects', function(hooks) {
test('sortable object renders', async function(assert) {
assert.expect(3);

await render(hbs`{{sortable-objects}}`);
await render(hbs`<SortableObjects />`);

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

await render(hbs`
{{#sortable-objects}}
<SortableObjects>
template block text
{{/sortable-objects}}
</SortableObjects>
`);

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

await render(hbs`
{{#sortable-objects}}
{{#draggable-object class='draggable-object'}}
<SortableObjects>
<DraggableObject class='draggable-object'>
Object 1
{{/draggable-object}}
{{#draggable-object class='draggable-object'}}
</DraggableObject>
<DraggableObject class='draggable-object'>
Object 2
{{/draggable-object}}
{{/sortable-objects}}
</DraggableObject>
</SortableObjects>
`);
assert.equal(findAll('.draggable-object').length, 2);
});
Expand All @@ -73,13 +73,13 @@ module('Integration | Component | sortable objects', function(hooks) {
});

await render(hbs`
{{#sortable-objects sortableObjectList=pojoData sortEndAction=(action sortEndAction) class='sortContainer' sortingScope='sortable-objects'}}
{{#each pojoData as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=true sortingScope='sortable-objects'}}
<SortableObjects @sortableObjectList={{this.pojoData}} @sortEndAction={{fn this.sortEndAction}} class='sortContainer' @sortingScope='sortable-objects'>
{{#each this.pojoData as |item|}}
<DraggableObject @content={{item}} @overrideClass='sortObject' @isSortable={{true}} @sortingScope='sortable-objects'>
{{item.title}}
{{/draggable-object}}
</DraggableObject>
{{/each}}
{{/sortable-objects}}
</SortableObjects>
`);

assert.equal(findAll('.sortObject').length, 4, 'shows 4 sortable elements');
Expand Down Expand Up @@ -121,13 +121,13 @@ module('Integration | Component | sortable objects', function(hooks) {
});

await render(hbs`
{{#sortable-objects sortableObjectList=pojoData sortEndAction=(action sortEndAction) class='sortContainer' useSwap=false}}
{{#each pojoData as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=true}}
<SortableObjects @sortableObjectList={{this.pojoData}} @sortEndAction={{fn this.sortEndAction}} class='sortContainer' @useSwap={{false}}>
{{#each this.pojoData as |item|}}
<DraggableObject @content={{item}} @overrideClass='sortObject' @isSortable={{true}}>
{{item.title}}
{{/draggable-object}}
</DraggableObject>
{{/each}}
{{/sortable-objects}}
</SortableObjects>
`);

assert.equal(findAll('.sortObject').length, 4);
Expand Down Expand Up @@ -166,13 +166,13 @@ module('Integration | Component | sortable objects', function(hooks) {
});

await render(hbs`
{{#sortable-objects sortableObjectList=pojoData sortEndAction=(action sortEndAction) class='sortContainer' enableSort=false}}
{{#each pojoData as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=false}}
{{item.title}}
{{/draggable-object}}
<SortableObjects @sortableObjectList={{this.pojoData}} @sortEndAction={{fn this.sortEndAction}} class='sortContainer' @enableSort={{false}}>
{{#each this.pojoData as |item|}}
<DraggableObject @content={{item}} @overrideClass='sortObject' @isSortable={{false}}>
{{item.title}}
</DraggableObject>
{{/each}}
{{/sortable-objects}}
</SortableObjects>
`);

assert.equal(findAll('.sortObject').length, 4);
Expand Down Expand Up @@ -210,13 +210,13 @@ module('Integration | Component | sortable objects', function(hooks) {
this.set('pojoData', mutableData);

await render(hbs`
{{#sortable-objects sortableObjectList=pojoData class='sortContainer' useSwap=false inPlace=true}}
{{#each pojoData as |item|}}
{{#draggable-object content=item overrideClass='sortObject' isSortable=true}}
<SortableObjects @sortableObjectList={{this.pojoData}} @useSwap={{false}} @inPlace={{true}}>
{{#each this.pojoData as |item|}}
<DraggableObject @content={{item}} @overrideClass='sortObject' @isSortable={{true}}>
{{item.title}}
{{/draggable-object}}
</DraggableObject>
{{/each}}
{{/sortable-objects}}
</SortableObjects>
`);

assert.equal(findAll('.sortObject').length, 4);
Expand Down
118 changes: 0 additions & 118 deletions tests/unit/components/draggable-object-target-test.js

This file was deleted.

Loading

0 comments on commit 89c24a3

Please sign in to comment.