Skip to content

Commit cd57963

Browse files
committed
Add tests for new keyboard shortcuts
1 parent 2cb6302 commit cd57963

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/web_client_specs/annotationSpec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,38 @@ girderTest.promise.done(function () {
404404
expect($('button.h-draw[data-type="point"]').hasClass('active')).toBe(true);
405405
});
406406
});
407+
408+
it('check that keyboard shortcuts behave correctly', function () {
409+
runs(function () {
410+
// expect that hitting the 'n' key will stop drawing mode
411+
$('.h-image-body').trigger($.Event('keydown', {key: 'n'}));
412+
expect($('.h-draw.active').length).toBe(0);
413+
414+
// expect that hitting the 'n' key again will start drawing mode
415+
$('.h-image-body').trigger($.Event('keydown', {key: 'n'}));
416+
expect($('.h-draw.active').attr('data-type')).toBe('point');
417+
418+
// expect that hitting keyboard shortcut for each shape will
419+
// switch annotation mode to it
420+
$('.h-image-body').trigger($.Event('keydown', {key: 'r'}));
421+
expect($('.h-draw.active').attr('data-type')).toBe('rectangle');
422+
423+
$('.h-image-body').trigger($.Event('keydown', {key: 'o'}));
424+
expect($('.h-draw.active').attr('data-type')).toBe('point');
425+
426+
$('.h-image-body').trigger($.Event('keydown', {key: 'c'}));
427+
expect($('.h-draw.active').attr('data-type')).toBe('circle');
428+
429+
$('.h-image-body').trigger($.Event('keydown', {key: 'l'}));
430+
expect($('.h-draw.active').attr('data-type')).toBe('ellipse');
431+
432+
$('.h-image-body').trigger($.Event('keydown', {key: 'p'}));
433+
expect($('.h-draw.active').attr('data-type')).toBe('polygon');
434+
435+
$('.h-image-body').trigger($.Event('keydown', {key: 'i'}));
436+
expect($('.h-draw.active').attr('data-type')).toBe('line');
437+
});
438+
});
407439
});
408440

409441
describe('Annotation styles', function () {

0 commit comments

Comments
 (0)