model-helper: handle arrays with undefined items
This commit is contained in:
parent
511d955e2e
commit
536fa4c577
|
@ -79,7 +79,7 @@ var modelHelper = module.exports = {
|
||||||
out.type = modelHelper.getPropType(out.type);
|
out.type = modelHelper.getPropType(out.type);
|
||||||
|
|
||||||
if (out.type === 'array') {
|
if (out.type === 'array') {
|
||||||
var hasItemType = typeof prop.type !== 'string' && prop.type.length;
|
var hasItemType = typeof prop.type !== 'string' && prop.type[0];
|
||||||
|
|
||||||
if (hasItemType) {
|
if (hasItemType) {
|
||||||
var arrayProp = prop.type[0];
|
var arrayProp = prop.type[0];
|
||||||
|
|
|
@ -89,6 +89,16 @@ describe('model-helper', function() {
|
||||||
expect(prop).to.eql({ type: 'array' });
|
expect(prop).to.eql({ type: 'array' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('converts [undefined] type', function() {
|
||||||
|
var def = getDefinition({
|
||||||
|
// This value is somehow provided by loopback-boot called from
|
||||||
|
// loopback-workspace.
|
||||||
|
array: [undefined]
|
||||||
|
});
|
||||||
|
var prop = def.properties.array;
|
||||||
|
expect(prop).to.eql({ type: 'array' });
|
||||||
|
});
|
||||||
|
|
||||||
it('converts "array" type', function() {
|
it('converts "array" type', function() {
|
||||||
var def = getDefinition({
|
var def = getDefinition({
|
||||||
array: 'array'
|
array: 'array'
|
||||||
|
|
Loading…
Reference in New Issue