Redesign the interface around Scan and Library, classify uncatalogued books from similar ones
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
308c0e1ed3
commit
6cec404e21
71 files changed
+8634
-1502
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import type { Book } from '../shared/types.ts';
|
||||
import { composeNumber, findNeighbours } from './shelve.ts';
|
||||
|
||||
test('a number is composed from the neighbour class, a new cutter and the year', () => {
|
||||
assert.equal(composeNumber('GV199.42.U8 T74 2016', ['Nancy Pallister'], 'Hiking', 2025), 'GV199.42.U8 P35 2025');
|
||||
assert.equal(composeNumber('TX719.C454 2001', ['Samin Nosrat'], 'Salt fat acid heat', 2017), 'TX719.N67 2017');
|
||||
});
|
||||
|
||||
test('no year given leaves it off; an unreadable neighbour gives nothing', () => {
|
||||
assert.equal(composeNumber('TX719.C454 2001', ['Samin Nosrat'], 'x', null), 'TX719.N67');
|
||||
assert.equal(composeNumber('garbage', ['A'], 'x', 2000), null);
|
||||
});
|
||||
|
||||
test('neighbours: matches by title or author, only books with a readable number, capped', () => {
|
||||
const mk = (id: number, title: string, callNumber: string | null) =>
|
||||
({ id, title, authors: ['Ann Author'], callNumber } as Book);
|
||||
const books = [mk(1, 'Hiking', 'GV199.42 .U8'), mk(2, 'Hiking notes', null), mk(3, 'Other', 'QA76 .X')];
|
||||
assert.deepEqual(findNeighbours(books, 'hik').map(b => b.id), [1]);
|
||||
assert.deepEqual(findNeighbours(books, 'author').map(b => b.id), [1, 3]);
|
||||
assert.deepEqual(findNeighbours(books, 'author', 1).length, 1);
|
||||
assert.deepEqual(findNeighbours(books, ' '), []);
|
||||
});
|
||||
Reference in new issue
Block a user