Skip to content

Commit

Permalink
Update tests to reflect superclass allowance (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed Jun 1, 2021
1 parent 77ec7f4 commit 838a63d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
2 changes: 1 addition & 1 deletion frontend/src/semantic-search/chain-view-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('semantic search ChainView', function() {
expect(view.items.length).toBe(1);
await event(view.items[0], 'ready');
expect(view.items[0]['typeGroup']).toBeDefined();
expect(view.items[0]['typeGroup'].collection.length).toBe(3);
expect(view.items[0]['typeGroup'].collection.length).toBe(4);
});

it('can be constructed with a preselection', async function() {
Expand Down
61 changes: 36 additions & 25 deletions frontend/src/semantic-search/dropdown-view-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,43 @@ describe('semantic search DropdownView', function() {
expect(view.$('optgroup:nth-child(2)').prop('label')).toBe('apply logic');
expect(view.$('optgroup:nth-child(2) option').length).toBe(3);
expect(view.$('optgroup:nth-child(3)').prop('label')).toBe('expect type');
expect(view.$('optgroup:nth-child(3) option').length).toBe(3);
expect(view.$('optgroup:nth-child(3) option').length).toBe(4);
expect(view.$('optgroup:nth-child(3)').text()).toContain('Reader');
expect(view.$('optgroup:nth-child(3)').text()).not.toContain('Person');
expect(view.$('optgroup:nth-child(3)').text()).toContain('Person');
});

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, 'ready');
await event(view.predicateGroup.collection.at(0), 'change:classLabel');
expect(view.$('select optgroup').length).toBe(3);
expect(view.$('optgroup:nth-child(2)').prop('label')).toBe('apply logic');
expect(view.$('optgroup:nth-child(2) option').length).toBe(3);
expect(view.$('optgroup:nth-child(3)').prop('label')).toBe('apply filter');
expect(view.$('optgroup:nth-child(3) option').length).toBe(2);
expect(view.$('optgroup:nth-child(3)').text()).toContain('Is exactly');
expect(view.$('optgroup:nth-child(3)').text()).not.toContain('Is less than');
expect(view.$('optgroup:nth-child(4)').prop('label')).toBe('traverse predicate');
expect(view.$('optgroup:nth-child(4) option').length).toBe(2);
expect(view.$('optgroup:nth-child(4)').text()).toContain('description of');
})
);
it('can be constructed with a property', async function() {
const model = new Model({
precedent: ldChannel.request('obtain', readit('descriptionOf')),
});
const view = new Dropdown({ model });
await event(view, 'ready');
await event(view.typeGroup.collection, 'complete:all');
expect(view.$('select optgroup').length).toBe(2);
expect(view.$('optgroup:nth-child(2)').prop('label')).toBe('apply logic');
expect(view.$('optgroup:nth-child(2) option').length).toBe(3);
expect(view.$('optgroup:nth-child(3)').prop('label')).toBe('expect type');
expect(view.$('optgroup:nth-child(3) option').length).toBe(2);
expect(view.$('optgroup:nth-child(3)').text()).toContain('Reader');
expect(view.$('optgroup:nth-child(3)').text()).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, 'ready');
await event(view.predicateGroup.collection.at(0), 'change:classLabel');
expect(view.$('select optgroup').length).toBe(3);
expect(view.$('optgroup:nth-child(2)').prop('label')).toBe('apply logic');
expect(view.$('optgroup:nth-child(2) option').length).toBe(3);
expect(view.$('optgroup:nth-child(3)').prop('label')).toBe('apply filter');
expect(view.$('optgroup:nth-child(3) option').length).toBe(2);
expect(view.$('optgroup:nth-child(3)').text()).toContain('Is exactly');
expect(view.$('optgroup:nth-child(3)').text()).not.toContain('Is less than');
expect(view.$('optgroup:nth-child(4)').prop('label')).toBe('traverse predicate');
expect(view.$('optgroup:nth-child(4) option').length).toBe(2);
expect(view.$('optgroup:nth-child(4)').text()).toContain('description of');
});
});

0 comments on commit 838a63d

Please sign in to comment.