summaryrefslogtreecommitdiff
path: root/web/js/tests/search-parser.test.js
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-09 11:11:49 +0300
committerPaul Buetow <paul@buetow.org>2026-05-09 11:11:49 +0300
commit8c32cd117abe79f4ee6cff3a950ffc35c95faeff (patch)
tree5b63a4789351da4f2d9c1cd2e7007f67d43b3371 /web/js/tests/search-parser.test.js
parent59c8870061465142306e7a6e5d3fcb344686cfe9 (diff)
Refine media browsing and set covers
Diffstat (limited to 'web/js/tests/search-parser.test.js')
-rw-r--r--web/js/tests/search-parser.test.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/web/js/tests/search-parser.test.js b/web/js/tests/search-parser.test.js
new file mode 100644
index 0000000..8b8e287
--- /dev/null
+++ b/web/js/tests/search-parser.test.js
@@ -0,0 +1,33 @@
+import { parseQuery } from '../search.js';
+
+const failures = [];
+
+function assert(cond, msg) {
+ if (!cond) failures.push(msg || 'assertion failed');
+}
+
+function testSetFilter() {
+ const parsed = parseQuery('set:yoga');
+ assert(parsed.set === 'yoga', 'set token should parse set name');
+ assert(parsed.search === '', 'set token should not become text search');
+}
+
+function testQuotedSetFilter() {
+ const parsed = parseQuery('set:"Yoga Flow" type:video morning');
+ assert(parsed.set === 'Yoga Flow', 'quoted set token should preserve spaces');
+ assert(parsed.type === 'video', 'other filters should still parse');
+ assert(parsed.search === 'morning', 'free text should still parse');
+}
+
+console.log('Running search parser tests...');
+testSetFilter();
+testQuotedSetFilter();
+
+if (failures.length) {
+ console.error('FAILURES:');
+ failures.forEach((m) => console.error(' - ' + m));
+ process.exit(1);
+} else {
+ console.log('All search parser tests passed.');
+ process.exit(0);
+}