Skip to content
Snippets Groups Projects
Commit 348fa3d0 authored by Javier de la Rosa's avatar Javier de la Rosa
Browse files

Adding tests to check that after clicking on a result item it takes the user to the right canvas

parent 66cb7b93
No related branches found
No related tags found
No related merge requests found
...@@ -7,18 +7,19 @@ describe('Search tab', function() { ...@@ -7,18 +7,19 @@ describe('Search tab', function() {
this.searchURI = "/search?q=" this.searchURI = "/search?q="
this.eventEmitter = new Mirador.EventEmitter(); this.eventEmitter = new Mirador.EventEmitter();
this.jsonLd = getJSONFixture('scta-info-pl-zbsSII72.json'); this.jsonLd = getJSONFixture('searchManifest.json');
this.results = getJSONFixture('scta-info-pl-zbsSII72.results.json'); this.results = getJSONFixture('searchManifest.results.json');
this.manifest = new Mirador.Manifest(null, null, this.jsonLd); this.manifest = new Mirador.Manifest(null, null, this.jsonLd);
this.jsonLdNoSearch = getJSONFixture('BNF-condorcet-florus-dispersus-manifest.json'); 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.manifestNoSearch = new Mirador.Manifest(null, null, this.jsonLdNoSearch);
this.sandbox = sandbox(); this.sandbox = sandbox();
this.windowId = '380c9e54-7561-4010-a99f-f132f5dc13fd';
this.createSearchTab = function(manifest) { this.createSearchTab = function(manifest) {
return new Mirador.SearchTab({ return new Mirador.SearchTab({
manifest: manifest, manifest: manifest,
appendTo: _this.sandbox, appendTo: _this.sandbox,
windowId: 'dummyID', windowId: this.windowId,
canvasID: 1234, canvasID: 1234,
eventEmitter: _this.eventEmitter eventEmitter: _this.eventEmitter
}); });
...@@ -98,5 +99,22 @@ describe('Search tab', function() { ...@@ -98,5 +99,22 @@ describe('Search tab', function() {
this.sandbox.find('#search-within-form').trigger('submit'); this.sandbox.find('#search-within-form').trigger('submit');
expect(this.sandbox.find('.search-result')).not.toExist(); 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% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment