Rework scan screen, make lookups non-blocking, fix review findings
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
468cafc6db
commit
b5defb4e4f
46 files changed
+1957
-406
No files matched your search
@@ -0,0 +1,28 @@
|
||||
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 });
|
||||
|
||||
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'));
|
||||
});
|
||||
Reference in new issue
Block a user