Cards now carry a QR code holding the book's own record (call number, title, authors, ISBN, year), and the scanner reads it back to find or add that book. Call number selection no longer pads catalogue numbers with generated cutters. A number is "exact" only when it comes verbatim from a record for this edition; a bare class is a hint that steers the other-edition and similar-books lookups; a record fetched by LCCN must list the book's ISBN to count as this edition. "Look up again" bypasses every cached result, and shelf order breaks ties by author then title. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
29 lines
1.4 KiB
TypeScript
29 lines
1.4 KiB
TypeScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { normalizeTitle, recordMatches, titlesMatch } from './match.ts';
|
|
import type { MarcFields } from '../sources/marc.ts';
|
|
|
|
const rec = (title: string, names: string[]): MarcFields => ({ lccn: null, lcc: [], dewey: null, meta: { title, authors: [], subjects: [] }, names, topics: [], isbns: [] });
|
|
|
|
test('normalizeTitle', () => {
|
|
assert.equal(normalizeTitle('The Mythical Man-Month: Essays on Software'), 'mythical man month');
|
|
assert.equal(normalizeTitle('An Introduction!'), 'introduction');
|
|
});
|
|
|
|
test('titlesMatch: equal or prefix, nothing looser', () => {
|
|
assert.ok(titlesMatch('The mythical man-month :', 'Mythical Man-Month'));
|
|
assert.ok(titlesMatch('Dune', 'Dune Messiah'));
|
|
assert.ok(!titlesMatch('Dunes', 'Dune'));
|
|
assert.ok(!titlesMatch('', 'Dune'));
|
|
assert.ok(titlesMatch('Rust', 'The Rust Programming Language'));
|
|
});
|
|
|
|
test('recordMatches needs title and an author surname', () => {
|
|
const r = rec('The mythical man-month', ['Brooks, Frederick P.']);
|
|
assert.ok(recordMatches(r, 'The Mythical Man-Month: Essays', 'Frederick P. Brooks'));
|
|
assert.ok(recordMatches(r, 'Mythical Man-Month', 'Brooks, Frederick P.'));
|
|
assert.ok(!recordMatches(r, 'Mythical Man-Month', 'Tolkien'));
|
|
assert.ok(!recordMatches(r, 'Something Else', 'Brooks'));
|
|
assert.ok(recordMatches(rec('Dune', ['Smith, Bob', 'Herbert, Frank']), 'Dune', 'Frank Herbert'));
|
|
});
|