Skip to content

Commit

Permalink
Adding tests to check that after clicking on a result item it takes t…
Browse files Browse the repository at this point in the history
…he user to the right canvas
  • Loading branch information
versae committed Mar 21, 2017
1 parent 70b99ef commit e68959a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions spec/widgets/searchWithin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ describe('Search tab', function() {

this.searchURI = "/search?q="
this.eventEmitter = new Mirador.EventEmitter();
this.jsonLd = getJSONFixture('scta-info-pl-zbsSII72.json');
this.results = getJSONFixture('scta-info-pl-zbsSII72.results.json');
this.jsonLd = getJSONFixture('searchManifest.json');
this.results = getJSONFixture('searchManifest.results.json');
this.manifest = new Mirador.Manifest(null, null, this.jsonLd);
this.jsonLdNoSearch = getJSONFixture('BNF-condorcet-florus-dispersus-manifest.json');
this.noResults = getJSONFixture('scta-info-pl-zbsSII72.noresults.json');
this.noResults = getJSONFixture('searchManifest.noresults.json');
this.manifestNoSearch = new Mirador.Manifest(null, null, this.jsonLdNoSearch);
this.sandbox = sandbox();
this.windowId = '380c9e54-7561-4010-a99f-f132f5dc13fd';
this.createSearchTab = function(manifest) {
return new Mirador.SearchTab({
manifest: manifest,
appendTo: _this.sandbox,
windowId: 'dummyID',
windowId: this.windowId,
canvasID: 1234,
eventEmitter: _this.eventEmitter
});
Expand Down Expand Up @@ -98,5 +99,22 @@ describe('Search tab', function() {
this.sandbox.find('#search-within-form').trigger('submit');
expect(this.sandbox.find('.search-result')).not.toExist();
});

it('should allow clicking on results after searching for some text', function() {
this.sandbox.find('#search-within-form input.js-query').val('found');
this.sandbox.find('#search-within-form').trigger('submit');
var hit = this.sandbox.find('.result-paragraph').first();
expect(hit.trigger.bind(hit, 'click')).not.toThrow();
});

it('should navigate to a specific canvas after clicking on a search result', function() {
spyOn(this.eventEmitter, 'publish').and.callThrough();
this.sandbox.find('#search-within-form input.js-query').val('found');
this.sandbox.find('#search-within-form').trigger('submit');
var hit = this.sandbox.find('.result-paragraph').first(),
canvasId = hit.attr('data-canvasid');
hit.trigger('click');
expect(this.eventEmitter.publish).toHaveBeenCalledWith('SET_CURRENT_CANVAS_ID.' + this.windowId, canvasId);
});
});
});

0 comments on commit e68959a

Please sign in to comment.