Projekte: Reiter-Liste der sechs Ansichten als getestete Funktion
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d2d4ad9cfb
commit
5647412e34
2 files changed
+35
-1
No files matched your search
@@ -2,7 +2,7 @@ import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { loadModule } from './load.mjs'
|
||||
|
||||
const { projectCounts, projectsInView, viewShowing, matchesSearch, hiddenMatches } = await loadModule('src/lib/projectList.js')
|
||||
const { projectCounts, projectsInView, projectTabs, viewShowing, matchesSearch, hiddenMatches } = await loadModule('src/lib/projectList.js')
|
||||
|
||||
const P = [
|
||||
{ $id: 'a' },
|
||||
@@ -76,3 +76,21 @@ test('hiddenMatches: Treffer, die die aktuelle Ansicht ausblendet', () => {
|
||||
assert.deepEqual(hiddenMatches(list, 'everything', shk, { isAdmin: true }), [], 'zeigt schon alles')
|
||||
assert.deepEqual(hiddenMatches(list, 'all', (p) => matchesSearch(p, 'olz'), { isAdmin: true }), [])
|
||||
})
|
||||
|
||||
const counts = { all: 5, unassigned: 2, assigned: 3, archived: 4, templates: 1, everything: 10 }
|
||||
test('projectTabs: sechs Reiter für Admins, Wortlaut und Zähler', () => {
|
||||
assert.deepEqual(projectTabs(counts, { isAdmin: true }), [
|
||||
{ id: 'all', label: 'Aktive Projekte', count: 5 },
|
||||
{ id: 'unassigned', label: 'Unzugeordnet', count: 2 },
|
||||
{ id: 'assigned', label: 'Zugeordnet', count: 3 },
|
||||
{ id: 'templates', label: 'Vorlagen', count: 1 },
|
||||
{ id: 'archived', label: 'Archiviert', count: 4 },
|
||||
{ id: 'everything', label: 'Alle inkl. Archiv', count: 10 },
|
||||
])
|
||||
})
|
||||
test('projectTabs: ohne Admin keine Vorlagen, Zähler passen zur Ansicht', () => {
|
||||
assert.deepEqual(projectTabs(counts).map((t) => t.id), ['all', 'unassigned', 'assigned', 'archived', 'everything'])
|
||||
for (const t of projectTabs(projectCounts(P, { isAdmin: true }), { isAdmin: true })) {
|
||||
assert.equal(t.count, projectsInView(P, t.id, { isAdmin: true }).length)
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user