flaska/test/middlewares.test.mjs

25 lines
697 B
JavaScript
Raw Permalink Normal View History

import { Eltro as t, assert} from 'eltro'
import { QueryHandler } from '../flaska.mjs'
t.describe('#QueryHandler()', function() {
let queryHandler = QueryHandler()
t.test('should return a handler', function() {
assert.strictEqual(typeof(queryHandler), 'function')
})
t.test('should support separating query from request url', function() {
const assertItem1 = 'safdsfdsag'
const assertItem2 = 'hello%20world'
const ctx = {
req: {
url: `/some/path?item1=${assertItem1}&ITEM2=${assertItem2}`
}
}
queryHandler(ctx)
assert.strictEqual(ctx.query.get('item1'), assertItem1)
assert.strictEqual(ctx.query.get('ITEM2'), 'hello world')
})
})