jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

41 lines
1.0 KiB

const paramConverter = require('./paramconverter.js');
const { WEEK, DAY, HOUR } = require('./timeutils.js');
/*
const defaultOptions = {
timeFields: [],
trimFields: [],
allowedArrays: [],
numberFields: [],
numberArrays: [],
objectIdParams: [],
objectIdFields: [],
objectIdArrays: [],
processThreadIdParam: false,
processDateParam: false,
processMessageLength: false,
};
*/
describe('paramconverter', () => {
const cases = [
{
in: { options: { trimFields: ['username', 'password'] }, body: { username: 'trimmed ', password: 'trimmed ' } },
out: { username: 'trimmed', password: 'trimmed' }
},
{
in: { options: { timeFields: ['test'] }, body: { test: '1w2d3h' } },
out: { test: WEEK+(2*DAY)+(3*HOUR) }
},
//todo: add a bunch more
];
for(let i in cases) {
test(`should output ${cases[i].out} for an input of ${cases[i].in}`, () => {
const converter = paramConverter(cases[i].in.options);
converter({ body: cases[i].in.body }, {}, () => {});
expect(cases[i].in.body).toStrictEqual(cases[i].out);
});
}
});