UNPKG

@unito/integration-sdk

Version:

Integration SDK

35 lines (28 loc) 916 B
import express from 'express'; import assert from 'node:assert/strict'; import { describe, it } from 'node:test'; import extractSearch from '../../src/middlewares/search.js'; describe('search middleware', () => { it('data', () => { const request = { query: { search: 'foo bar spam baz' } } as express.Request< // eslint-disable-next-line @typescript-eslint/no-explicit-any any, object, object, { search: string } >; const response = { locals: {} } as express.Response; extractSearch(request, response, () => {}); assert.deepEqual(response.locals, { search: 'foo bar spam baz', }); }); it('no data', () => { const request = { query: {} } as express.Request; const response = { locals: {} } as express.Response; extractSearch(request, response, () => {}); assert.deepEqual(response.locals, { search: null, }); }); });