Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Jul 26, 2017
1 parent c11457e commit bacce90
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
describe('conflicts', () => {
it('returns a field for each in response, no filtering', () => {
const fields = readFieldCapsResponse(esResponse);
expect(fields).to.have.length(13);
expect(fields).to.have.length(19);
});

it('includes only name, type, searchable, aggregatable, readFromDocValues, and maybe conflictDescriptions of each field', () => {
Expand Down Expand Up @@ -65,8 +65,8 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
{
name: 'success',
type: 'conflict',
searchable: false,
aggregatable: false,
searchable: true,
aggregatable: true,
readFromDocValues: false,
conflictDescriptions: {
boolean: [
Expand All @@ -79,6 +79,30 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
}
]);
});

it('does not return conflicted fields if the types are resolvable to the same kibana type', () => {
const fields = readFieldCapsResponse(esResponse);
const resolvableToString = fields.find(f => f.name === 'resolvable_to_string');
const resolvableToNumber = fields.find(f => f.name === 'resolvable_to_number');
expect(resolvableToString.type).to.be('string');
expect(resolvableToNumber.type).to.be('number');
});

it('returns aggregatable if at least one field is aggregatable', () => {
const fields = readFieldCapsResponse(esResponse);
const mixAggregatable = fields.find(f => f.name === 'mix_aggregatable');
const mixAggregatableOther = fields.find(f => f.name === 'mix_aggregatable_other');
expect(mixAggregatable.aggregatable).to.be(true);
expect(mixAggregatableOther.aggregatable).to.be(true);
});

it('returns searchable if at least one field is searchable', () => {
const fields = readFieldCapsResponse(esResponse);
const mixSearchable = fields.find(f => f.name === 'mix_searchable');
const mixSearchableOther = fields.find(f => f.name === 'mix_searchable_other');
expect(mixSearchable.searchable).to.be(true);
expect(mixSearchableOther.searchable).to.be(true);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,98 @@
"searchable": false,
"aggregatable": true
}
},
"resolvable_to_string": {
"text": {
"type": "text",
"searchable": true,
"aggregatable": true,
"indices": [
"index1"
]
},
"keyword": {
"type": "keyword",
"searchable": true,
"aggregatable": true,
"indices": [
"index2"
]
}
},
"resolvable_to_number": {
"integer": {
"type": "integer",
"searchable": true,
"aggregatable": true,
"indices": [
"index1"
]
},
"long": {
"type": "long",
"searchable": true,
"aggregatable": true,
"indices": [
"index2"
]
}
},
"mix_searchable": {
"text": {
"type": "text",
"searchable": false,
"aggregatable": true,
"indices": [
"index1"
]
},
"keyword": {
"type": "keyword",
"searchable": true,
"aggregatable": true,
"indices": [
"index2"
]
}
},
"mix_aggregatable": {
"text": {
"type": "text",
"searchable": true,
"aggregatable": false,
"indices": [
"index1"
]
},
"keyword": {
"type": "keyword",
"searchable": true,
"aggregatable": true,
"indices": [
"index2"
]
}
},
"mix_searchable_other": {
"int": {
"type": "integer",
"searchable": false,
"aggregatable": false,
"non_searchable_indices": [
"index1"
]
}
},
"mix_aggregatable_other": {
"int": {
"type": "integer",
"searchable": false,
"aggregatable": false,
"non_aggregatable_indices": [
"index1"
]
}
}
}
}

0 comments on commit bacce90

Please sign in to comment.