From fd732d6e10b35e895d40436efd54bc1ccdd5b64f Mon Sep 17 00:00:00 2001 From: "Daniel W. Hieber" Date: Fri, 19 Jul 2024 15:56:02 -0500 Subject: [PATCH] FIX: Broken Tests --- pages/Search/Search.js | 6 ++++-- pages/Search/Search.test.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pages/Search/Search.js b/pages/Search/Search.js index 85cefd4e..189375be 100644 --- a/pages/Search/Search.js +++ b/pages/Search/Search.js @@ -35,18 +35,20 @@ export function Search(req, res) { let { limit = 100, offset = 0, + q, sort = ``, } = req.query const { diacritics, language, - q, } = req.query // Search - let results = req.app.db.search(q.trim(), { diacritics, language }) + q = q.trim().normalize() // Normalize search text since data in database is also normalized. + + let results = req.app.db.search(q, { diacritics, language }) const numTotalResults = results.length // Sort diff --git a/pages/Search/Search.test.js b/pages/Search/Search.test.js index 96eb0cbc..3bd73b49 100644 --- a/pages/Search/Search.test.js +++ b/pages/Search/Search.test.js @@ -57,7 +57,7 @@ describe(`Search`, function() { cy.get(`#diacritics-box`).check() cy.get(`#search-box`).type(`aštimw`) cy.get(`form`).submit() - cy.get(`.num-results`).should(`include.text`, `of 1`) + cy.get(`.num-results`).should(`include.text`, `of 2`) }) it(`Form (Project)`, function() { @@ -158,7 +158,7 @@ describe(`Search`, function() { // Return first page of results by default cy.get(`#results td`).first().should(`have.text`, `Abenaki`) .next() - .should(`have.text`, `ôben-`) + .should(`have.text`, `ɔ̃ben-`) // Showing X of Y results. cy.get(`.num-results`).invoke(`text`).should(`match`, /^Showing results 1–100 of .+?\.$/v)