43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
/**
|
|
* Candidate browse queue — unique ids, neighbors, profile paths.
|
|
*
|
|
* node candidate-browse.test.mjs
|
|
*/
|
|
import assert from 'node:assert/strict'
|
|
import { uniqueBrowseEntries, neighborsOf, candidatePath } from './src/lib/candidateBrowse.js'
|
|
|
|
const rows = [
|
|
{ userId: 'a', name: 'Ada', stage: 'Interview', jobTitle: 'Backend' },
|
|
{ user_id: 'a', name: 'Ada duplicate application' },
|
|
{ userId: '', name: 'Skipped' },
|
|
{ userId: 'b', email: 'b@example.com' },
|
|
{ userId: 'c', name: 'Chris', job_title: 'Design' },
|
|
]
|
|
|
|
const entries = uniqueBrowseEntries(rows)
|
|
assert.deepEqual(entries.map((row) => row.userId), ['a', 'b', 'c'])
|
|
assert.equal(entries[0].name, 'Ada')
|
|
assert.equal(entries[0].stage, 'Interview')
|
|
assert.equal(entries[1].name, 'b@example.com')
|
|
assert.equal(entries[2].jobTitle, 'Design')
|
|
|
|
const mid = neighborsOf(entries, 'b')
|
|
assert.equal(mid.index, 1)
|
|
assert.equal(mid.total, 3)
|
|
assert.equal(mid.prev.userId, 'a')
|
|
assert.equal(mid.next.userId, 'c')
|
|
|
|
const first = neighborsOf(entries, 'a')
|
|
assert.equal(first.prev, null)
|
|
assert.equal(first.next.userId, 'b')
|
|
|
|
const missing = neighborsOf(entries, 'z')
|
|
assert.equal(missing.index, -1)
|
|
assert.equal(missing.prev, null)
|
|
assert.equal(missing.next, null)
|
|
|
|
assert.equal(candidatePath('user/1'), '/candidate/user%2F1')
|
|
assert.equal(candidatePath('abc', 'Resume'), '/candidate/abc?tab=Resume')
|
|
|
|
console.log('All candidate browse checks passed')
|