-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug where queue message wasn't visible to students (#214)
* Fix bug where queue message wasn't visible to students * Add Changelog entry * Add basic tests for QueueMessageViewer * Fix linter error
- Loading branch information
1 parent
a588b83
commit c0bcf64
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-env jest */ | ||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
import { Collapse } from 'reactstrap' | ||
import QueueMessageViewer from './QueueMessageViewer' | ||
|
||
const makeProps = (props = {}) => { | ||
const noop = () => {} | ||
return { | ||
collapsible: props.collapsible || false, | ||
onEdit: props.onEdit || noop, | ||
queueId: 1, | ||
message: props.message || '', | ||
editable: props.editable || false, | ||
} | ||
} | ||
|
||
const makeWrapper = props => | ||
shallow(<QueueMessageViewer {...makeProps(props)} />) | ||
|
||
describe('<QueueMessageViewer />', () => { | ||
it('shows the expanded message if not collapsible', () => { | ||
const wrapper = makeWrapper({ collapsible: false }) | ||
const collapse = wrapper.find(Collapse) | ||
expect(collapse.prop('isOpen')).toBeTruthy() | ||
}) | ||
|
||
it('shows edit button if editable', () => { | ||
const wrapper = makeWrapper({ editable: true }) | ||
const button = wrapper.find('[aria-label="Edit message"]') | ||
expect(button).toHaveLength(1) | ||
}) | ||
|
||
it('hides edit button if not editable', () => { | ||
const wrapper = makeWrapper({ editable: false }) | ||
const button = wrapper.find('[aria-label="Edit message"]') | ||
expect(button).toHaveLength(0) | ||
}) | ||
}) |