Commit b6741e51 authored by Robert Knight's avatar Robert Knight

Add tests for sidebar closing when user clicks or taps in document

parent 96a03306
......@@ -176,6 +176,9 @@ module.exports = class Sidebar extends Host
.removeClass('h-icon-chevron-right')
.addClass('h-icon-chevron-left')
isOpen: ->
!@frame.hasClass('annotator-collapsed')
createAnnotation: (annotation = {}) ->
super
this.show() unless annotation.$highlight
......
......@@ -173,3 +173,16 @@ describe 'Sidebar', ->
hide = sandbox.stub(sidebar, 'hide')
sidebar.onSwipe({type: 'swiperight'})
assert.calledOnce(hide)
describe 'document events', ->
sidebar = null
beforeEach ->
sidebar = createSidebar({})
it 'closes the sidebar when the user taps or clicks in the page', ->
for event in ['click', 'touchstart']
sidebar.show()
sidebar.element.trigger(event)
assert.isFalse(sidebar.isOpen())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment