Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('reports error if an array parameter type is not Array', () => {
expect.throws(
() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
class MyController {
@get('/greet')
greet(
@param.array('names', 'query', {type: 'string'}) names: string,
) {}
}
},
Error,
`The parameter type is set to 'array' but the JavaScript type is String`,
);
});
it('throws when @property.array is used on a non-array property', () => {
expect.throws(
() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
class Oops {
@property.array(Product)
product: Product;
}
},
Error,
property.ERR_PROP_NOT_ARRAY,
);
});
});
it('errors if type is an array and items is missing', () => {
expect.throws(
() => {
jsonToSchemaObject({type: 'array'});
},
Error,
'"items" property must be present if "type" is an array',
);
});
it('when attempting to bind an array of servers', () => {
const app = new RestApplication();
expect.throws(
() => {
app.servers([RestServer, RestServer]);
},
Error,
ERR_NO_MULTI_SERVER,
);
});