diff --git a/frontend/src/semantic-search/dropdown-view-test.ts b/frontend/src/semantic-search/dropdown-view-test.ts index 799665e1..7aed0dd7 100644 --- a/frontend/src/semantic-search/dropdown-view-test.ts +++ b/frontend/src/semantic-search/dropdown-view-test.ts @@ -1,4 +1,4 @@ -import { constant } from 'lodash'; +import { constant, each } from 'lodash'; import { enableI18n, startStore, endStore, event } from '../test-util'; import mockOntology from '../mock-data/mock-ontology'; @@ -37,21 +37,26 @@ describe('semantic search DropdownView', function() { expect(view.$('optgroup:nth-child(2)').text()).not.toContain('Person'); }); - it('can be constructed with a single class', async function() { - const model = new Model({ - precedent: ldChannel.request('obtain', readit('Reader')), - }); - const view = new Dropdown({ model }); - await event(view.predicateGroup.collection.at(0), 'change:classLabel'); - expect(view.$('select optgroup').length).toBe(3); - expect(view.$('optgroup:first-child').prop('label')).toBe('apply logic'); - expect(view.$('optgroup:first-child option').length).toBe(3); - expect(view.$('optgroup:nth-child(2)').prop('label')).toBe('apply filter'); - expect(view.$('optgroup:nth-child(2) option').length).toBe(2); - expect(view.$('optgroup:nth-child(2)').text()).toContain('Is exactly'); - expect(view.$('optgroup:nth-child(2)').text()).not.toContain('Is less than'); - expect(view.$('optgroup:nth-child(3)').prop('label')).toBe('traverse predicate'); - expect(view.$('optgroup:nth-child(3) option').length).toBe(2); - expect(view.$('optgroup:nth-child(3)').text()).toContain('description of'); - }); + each({ + 'single class': 'Reader', + 'property': 'descriptionOf', + }, (term, label) => + it(`can be constructed with a ${label}`, async function() { + const model = new Model({ + precedent: ldChannel.request('obtain', readit(term)), + }); + const view = new Dropdown({ model }); + await event(view.predicateGroup.collection.at(0), 'change:classLabel'); + expect(view.$('select optgroup').length).toBe(3); + expect(view.$('optgroup:first-child').prop('label')).toBe('apply logic'); + expect(view.$('optgroup:first-child option').length).toBe(3); + expect(view.$('optgroup:nth-child(2)').prop('label')).toBe('apply filter'); + expect(view.$('optgroup:nth-child(2) option').length).toBe(2); + expect(view.$('optgroup:nth-child(2)').text()).toContain('Is exactly'); + expect(view.$('optgroup:nth-child(2)').text()).not.toContain('Is less than'); + expect(view.$('optgroup:nth-child(3)').prop('label')).toBe('traverse predicate'); + expect(view.$('optgroup:nth-child(3) option').length).toBe(2); + expect(view.$('optgroup:nth-child(3)').text()).toContain('description of'); + }) + ); });