Add more integration tests #31
@ -225,7 +225,7 @@ test('crud#list handler with order', async (t) => {
|
|||||||
|
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
findAllArgs.order,
|
findAllArgs.order,
|
||||||
[request.query.order],
|
[[request.query.order]],
|
||||||
'queries with the order as an array b/c that\'s what sequelize wants'
|
'queries with the order as an array b/c that\'s what sequelize wants'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -144,7 +144,7 @@ export default ({
|
|||||||
.keys({
|
.keys({
|
||||||
limit: joi.number().min(0).integer(),
|
limit: joi.number().min(0).integer(),
|
||||||
offset: joi.number().min(0).integer(),
|
offset: joi.number().min(0).integer(),
|
||||||
order: joi.array(),
|
order: [joi.array(), joi.string()],
|
||||||
}),
|
}),
|
||||||
get(methodConfig, 'validate.query')
|
get(methodConfig, 'validate.query')
|
||||||
);
|
);
|
||||||
|
@ -70,7 +70,7 @@ export const parseOrder = (request) => {
|
|||||||
|
|
||||||
// transform to an array so sequelize will escape the input for us and
|
// transform to an array so sequelize will escape the input for us and
|
||||||
// maintain security. See http://docs.sequelizejs.com/en/latest/docs/querying/#ordering
|
// maintain security. See http://docs.sequelizejs.com/en/latest/docs/querying/#ordering
|
||||||
if (isString(order)) return order.split(' ');
|
if (isString(order)) return [order.split(' ')];
|
||||||
|
|
||||||
for (const key of Object.keys(order)) {
|
for (const key of Object.keys(order)) {
|
||||||
try {
|
try {
|
||||||
@ -80,7 +80,7 @@ export const parseOrder = (request) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return order;
|
return [order];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMethod = (model, association, plural = true, method = 'get') => {
|
export const getMethod = (model, association, plural = true, method = 'get') => {
|
||||||
|
@ -57,7 +57,7 @@ test('parseOrder returns order when a string', (t) => {
|
|||||||
|
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
parseOrder(request)
|
parseOrder(request)
|
||||||
, [order]
|
, [[order]]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ test('parseOrder returns order when json', (t) => {
|
|||||||
|
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
parseOrder(request)
|
parseOrder(request)
|
||||||
, order
|
, [order]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user