From 92510ca486ec9e9901c4a3c27b245d3f1edec3c2 Mon Sep 17 00:00:00 2001 From: Jonas Earendel Date: Tue, 19 Sep 2023 15:37:37 +0200 Subject: [PATCH] some more tests --- src/sortable.test.html | 14 +++++++++++++- src/sortable.test.js | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/sortable.test.html b/src/sortable.test.html index 1bf9c48..2bf2197 100644 --- a/src/sortable.test.html +++ b/src/sortable.test.html @@ -134,22 +134,34 @@

class="no-sort"

-

times

+

numeric sorting

+ + + + + + + + + + + +
Role TimeAmountNumber
Genius 12:00:12$18.492.49
Sidekick 12:22:11$2.4918.49
Butler12:22:05$1.961.96
diff --git a/src/sortable.test.js b/src/sortable.test.js index 72b0a7d..0e622d7 100644 --- a/src/sortable.test.js +++ b/src/sortable.test.js @@ -134,4 +134,30 @@ describe('sortable.test.html', () => { expect(middle).toBe('12:22:11') expect(last).toBe('12:00:12') }) + + it('treats amounts like strings', async () => { + const table = getAllByRole(container, 'table')[5] + const th = getByRole(table, 'columnheader', { name: /Amount/ }) + const first = getAllByRole(table, 'cell')[2].textContent + fireEvent.click(th) + const middle = getAllByRole(table, 'cell')[2].textContent + fireEvent.click(th) + const last = getAllByRole(table, 'cell')[2].textContent + expect(first).toBe('$18.49') + expect(middle).toBe('$2.49') + expect(last).toBe('$1.96') + }) + + it('treats numbers like numbers', async () => { + const table = getAllByRole(container, 'table')[5] + const th = getByRole(table, 'columnheader', { name: /Number/ }) + const first = getAllByRole(table, 'cell')[3].textContent + fireEvent.click(th) + const middle = getAllByRole(table, 'cell')[3].textContent + fireEvent.click(th) + const last = getAllByRole(table, 'cell')[3].textContent + expect(first).toBe('2.49') + expect(middle).toBe('18.49') + expect(last).toBe('1.96') + }) })