-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve the action helper/modifier deprecation
- Loading branch information
Showing
6 changed files
with
211 additions
and
33 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
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
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
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
115 changes: 115 additions & 0 deletions
115
tests/integration/components/au-data-table/au-data-table-number-pagination-test.js
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,115 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { getRootElement, click, render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import { queryByText } from '@testing-library/dom'; | ||
|
||
module( | ||
'Integration | Component | au-data-table-number-pagination', | ||
function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it conditionally shows buttons to change the page', async function (assert) { | ||
const baseLinks = { | ||
first: { | ||
number: 0, | ||
}, | ||
last: { | ||
number: 9, | ||
}, | ||
}; | ||
|
||
this.set('page', 1); | ||
this.set('links', { | ||
...baseLinks, | ||
prev: { | ||
number: 0, | ||
}, | ||
next: { | ||
number: 2, | ||
}, | ||
}); | ||
|
||
await render( | ||
hbs` | ||
<AuDataTableNumberPagination | ||
@page={{this.page}} | ||
@links={{this.links}} | ||
@size={{10}} | ||
@nbOfItems={{10}} | ||
@total={{100}} | ||
/> | ||
`, | ||
); | ||
|
||
const root = getRootElement(); | ||
let prevButton = queryByText(root, 'vorige'); | ||
let nextButton = queryByText(root, 'volgende'); | ||
|
||
assert.ok( | ||
prevButton, | ||
"It shows a button to go to the previous page when we aren't on the first page", | ||
); | ||
assert.ok( | ||
nextButton, | ||
"It shows a button to go to the next page when we aren't on the last page", | ||
); | ||
|
||
await click(prevButton); | ||
assert.equal( | ||
this.page, | ||
0, | ||
'It updates the @page value with 2-way-binding', | ||
); | ||
|
||
this.set('links', { | ||
...baseLinks, | ||
next: { | ||
number: 1, | ||
}, | ||
}); | ||
|
||
prevButton = queryByText(root, 'vorige'); | ||
assert.notOk( | ||
prevButton, | ||
'It hides the button to go to the previous page when we are on the first page', | ||
); | ||
|
||
nextButton = queryByText(root, 'volgende'); | ||
assert.ok(nextButton); | ||
|
||
await click(nextButton); | ||
assert.equal( | ||
this.page, | ||
1, | ||
'It updates the @page value with 2-way-binding', | ||
); | ||
this.set('links', { | ||
...baseLinks, | ||
prev: { | ||
number: 0, | ||
}, | ||
next: { | ||
number: 2, | ||
}, | ||
}); | ||
|
||
prevButton = queryByText(root, 'vorige'); | ||
assert.ok(prevButton); | ||
|
||
this.set('page', 9); | ||
this.set('links', { | ||
...baseLinks, | ||
prev: { | ||
number: 8, | ||
}, | ||
}); | ||
|
||
nextButton = queryByText(root, 'volgende'); | ||
assert.notOk( | ||
nextButton, | ||
'It hides the button to go to the next page when we are on the last page', | ||
); | ||
}); | ||
}, | ||
); |
67 changes: 67 additions & 0 deletions
67
tests/integration/components/au-data-table/au-data-table-th-sortable-test.js
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,67 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { getRootElement, click, render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import { queryByText } from '@testing-library/dom'; | ||
|
||
module('Integration | Component | au-data-table-th-sortable', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it switches between the different sorting states when the button is clicked', async function (assert) { | ||
this.set('sort', ''); | ||
|
||
await render( | ||
hbs` | ||
<AuDataTableThSortable | ||
@field="foo" | ||
@label="Foo" | ||
@currentSorting={{this.sort}} | ||
/> | ||
`, | ||
); | ||
|
||
const root = getRootElement(); | ||
let sortButton = queryByText(root, 'Sorteren'); | ||
|
||
assert.ok( | ||
sortButton, | ||
"It shows a sort button if we aren't currently sorting on the field that matches the component", | ||
); | ||
|
||
await click(sortButton); | ||
assert.equal( | ||
this.sort, | ||
'foo', | ||
'It updates the sort value with 2-way-binding. It initially sorts ascending.', | ||
); | ||
|
||
sortButton = queryByText(root, 'Sorteren'); | ||
assert.notOk( | ||
sortButton, | ||
'It hides the default sort button when we are sorting on the field that matches the component', | ||
); | ||
|
||
sortButton = queryByText(root, 'Aflopend sorteren'); | ||
assert.ok( | ||
sortButton, | ||
'It shows the sort descending button when we are currently sorting ascending on the field that matches the component', | ||
); | ||
|
||
await click(sortButton); | ||
assert.equal( | ||
this.sort, | ||
'-foo', | ||
'It switches to a descending sort for the provided field', | ||
); | ||
|
||
sortButton = queryByText(root, 'Aflopend sorteren'); | ||
assert.notOk(sortButton); | ||
|
||
// TODO: this logic isn't correct I think since we stop sorting when we click again? | ||
sortButton = queryByText(root, 'Oplopend sorteren'); | ||
assert.ok(sortButton); | ||
|
||
await click(sortButton); | ||
assert.equal(this.sort, '', 'It stops sorting on the provided field'); | ||
}); | ||
}); |