Skip to content

Commit

Permalink
Adding test to check that user is taken to the annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
versae committed Mar 21, 2017
1 parent 644862a commit 26e5384
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions spec/widgets/searchWithin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,20 @@ describe('Search tab', function() {
expect(hit.trigger.bind(hit, 'click')).not.toThrow();
});

it('should navigate to a specific canvas after clicking on a search result', function() {
it('should navigate to a specific canvas and bounds 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');
canvasID = hit.attr('data-canvasid'),
coordinates = hit.attr('data-coordinates'),
xywh = coordinates && coordinates.split('=')[1].split(',').map(Number),
bounds = xywh && {x: xywh[0], y: xywh[1], width: xywh[2], height: xywh[3]};
hit.trigger('click');
expect(this.eventEmitter.publish).toHaveBeenCalledWith('SET_CURRENT_CANVAS_ID.' + this.windowId, canvasId);
expect(this.eventEmitter.publish).toHaveBeenCalledWith('SET_CURRENT_CANVAS_ID.' + this.windowId, {
"canvasID": canvasID,
"bounds": bounds
});
});
});
});

0 comments on commit 26e5384

Please sign in to comment.